1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00

Update chromecast libs

This commit is contained in:
DanieL 2022-06-30 12:14:30 -03:00
parent 4a192d434b
commit bfcb7b3544
1433 changed files with 740 additions and 132979 deletions

View file

@ -70,8 +70,8 @@ const Controller = function(player, options) {
timeout: this.settings.timeout,
prerollTimeout: this.settings.prerollTimeout,
};
const adsPluginSettings = this.extend(
{}, contribAdsDefaults, options.contribAdsSettings || {});
const adsPluginSettings =
Object.assign({}, contribAdsDefaults, options.contribAdsSettings || {});
this.playerWrapper = new PlayerWrapper(player, adsPluginSettings, this);
this.adUi = new AdUi(this);
@ -97,7 +97,7 @@ Controller.IMA_DEFAULTS = {
* @param {Object} options Options to be used in initialization.
*/
Controller.prototype.initWithSettings = function(options) {
this.settings = this.extend({}, Controller.IMA_DEFAULTS, options || {});
this.settings = Object.assign({}, Controller.IMA_DEFAULTS, options || {});
this.warnAboutDeprecatedSettings();
@ -156,6 +156,7 @@ Controller.prototype.getIsIos = function() {
return this.isIos;
};
/**
* Inject the ad container div into the DOM.
*
@ -165,6 +166,7 @@ Controller.prototype.injectAdContainerDiv = function(adContainerDiv) {
this.playerWrapper.injectAdContainerDiv(adContainerDiv);
};
/**
* @return {HTMLElement} The div for the ad container.
*/
@ -675,7 +677,7 @@ Controller.prototype.playAdBreak = function() {
/**
* Adds an EventListener to the AdsManager. For a list of available events,
* Ads an EventListener to the AdsManager. For a list of available events,
* see
* https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdEvent#.Type
* @param {google.ima.AdEvent.Type} event The AdEvent.Type for which to
@ -777,29 +779,4 @@ Controller.prototype.triggerPlayerEvent = function(name, data) {
this.playerWrapper.triggerPlayerEvent(name, data);
};
/**
* Extends an object to include the contents of objects at parameters 2 onward.
*
* @param {Object} obj The object onto which the subsequent objects' parameters
* will be extended. This object will be modified.
* @param {...Object} var_args The objects whose properties are to be extended
* onto obj.
* @return {Object} The extended object.
*/
Controller.prototype.extend = function(obj, ...args) {
let arg;
let index;
let key;
for (index = 0; index < args.length; index++) {
arg = args[index];
for (key in arg) {
if (arg.hasOwnProperty(key)) {
obj[key] = arg[key];
}
}
}
return obj;
};
export default Controller;

View file

@ -663,7 +663,6 @@ SdkImpl.prototype.onPlayerResize = function(width, height) {
if (this.adsManager) {
this.adsManagerDimensions.width = width;
this.adsManagerDimensions.height = height;
/* global google */
/* eslint no-undef: 'error' */
this.adsManager.resize(width, height, google.ima.ViewMode.NORMAL);
}

View file

@ -257,7 +257,8 @@ DaiController.prototype.addEventListener = function(event, callback) {
/**
* Returns the instance of the StreamManager.
* @return {google.ima.StreamManager!} The StreamManager being used by the plugin.
* @return {google.ima.StreamManager!} The StreamManager being used by the
* plugin.
*/
DaiController.prototype.getStreamManager = function() {
return this.sdkImpl.getStreamManager();
@ -272,7 +273,8 @@ DaiController.prototype.getPlayerId = function() {
};
/**
* @return {boolean} true if we expect that the stream will autoplay. false otherwise.
* @return {boolean} true if we expect that the stream will autoplay. false
* otherwise.
*/
DaiController.prototype.streamWillAutoplay = function() {
if (this.settings.streamWillAutoplay !== undefined) {
@ -291,4 +293,4 @@ DaiController.prototype.triggerPlayerEvent = function(name, data) {
this.playerWrapper.triggerPlayerEvent(name, data);
};
export default DaiController;
export default DaiController;

View file

@ -169,4 +169,4 @@ PlayerWrapper.prototype.reset = function() {
this.vjsControls.show();
};
export default PlayerWrapper;
export default PlayerWrapper;

View file

@ -20,7 +20,8 @@
/**
* Implementation of the IMA DAI SDK for the plugin.
*
* @param {DaiController!} daiController Reference to the parent DAI controller.
* @param {DaiController!} daiController Reference to the parent DAI
* controller.
*
* @constructor
* @struct
@ -132,7 +133,6 @@ SdkImpl.prototype.initImaDai = function() {
*/
SdkImpl.prototype.onAddTrack = function(event) {
const track = event.track;
console.log('TRACK', track);
if (track.kind === 'metadata') {
track.mode = 'hidden';
track.oncuechange = (e) => {
@ -207,13 +207,11 @@ SdkImpl.prototype.onStreamPause = function() {
this.loadUrl(event.getStreamData().url);
break;
case google.ima.dai.api.StreamEvent.Type.ERROR:
const errorMessage = event.getStreamData().errorMessage;
window.console.warn('Error loading stream, attempting to play backup stream. '
+ errorMessage);
window.console.warn('Error loading stream, attempting to play backup ' +
'stream. ' + event.getStreamData().errorMessage);
this.daiController.onErrorLoadingAds(event);
const fallbackUrl = this.daiController.getSettings().fallbackStreamUrl;
if (fallbackUrl) {
this.loadurl(fallbackUrl);
if (this.daiController.getSettings().fallbackStreamUrl) {
this.loadurl(this.daiController.getSettings().fallbackStreamUrl);
}
break;
case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:
@ -225,8 +223,8 @@ SdkImpl.prototype.onStreamPause = function() {
this.isAdBreak = false;
this.adUiDiv.style.display = 'none';
this.daiController.onAdBreakEnd();
const currentTime = this.vjsPlayer.currentTime();
if (this.snapForwardTime && this.snapForwardTime > currentTime) {
if (this.snapForwardTime && this.snapForwardTime >
this.vjsPlayer.currentTime()) {
this.vjsPlayer.currentTime(this.snapForwardTime);
this.snapForwardTime = 0;
}
@ -250,7 +248,8 @@ SdkImpl.prototype.loadUrl = function(streamUrl) {
const bookmarkTime = this.daiController.getSettings().bookmarkTime;
if (bookmarkTime) {
const startTime = this.streamManager.streamTimeForContentTime(bookmarkTime);
const startTime =
this.streamManager.streamTimeForContentTime(bookmarkTime);
// Seeking on load triggers the onSeekEnd event, so treat this seek as
// if it's snapback. Without this, resuming at a bookmark kicks you
// back to the ad before the bookmark.
@ -285,7 +284,8 @@ SdkImpl.prototype.requestStream = function() {
streamRequest.authKey = this.daiController.getSettings().authKey;
}
if (this.daiController.getSettings().adTagParameters) {
streamRequest.adTagParameters = this.daiController.getSettings().adTagParameters;
streamRequest.adTagParameters =
this.daiController.getSettings().adTagParameters;
}
if (this.daiController.getSettings().streamActivityMonitorId) {
streamRequest.streamActivityMonitorId =
@ -336,7 +336,8 @@ SdkImpl.prototype.onPlayerDisposed = function() {
/**
* Returns the instance of the StreamManager.
* @return {google.ima.StreamManager!} The StreamManager being used by the plugin.
* @return {google.ima.StreamManager!} The StreamManager being used by the
* plugin.
*/
SdkImpl.prototype.getStreamManager = function() {
return this.StreamManager;
@ -352,4 +353,4 @@ SdkImpl.prototype.reset = function() {
}
};
export default SdkImpl;
export default SdkImpl;

View file

@ -234,11 +234,9 @@ const ImaDaiPlugin = function(player, options) {
}.bind(this);
/**
* Adds an EventListener to the StreamManager. For a list of available events,
* see
* https://developers.google.com/interactive-media-ads/docs/sdks/html5/dai/reference/js/StreamEvent
* @param {google.ima.StreamEvent.Type} event The StreamEvent.Type for which to
* listen.
* Adds an EventListener to the StreamManager.
* @param {google.ima.StreamEvent.Type} event The StreamEvent.Type for which
* to listen.
* @param {callback} callback The method to call when the event is fired.
*/
this.addEventListener = function(event, callback) {
@ -247,19 +245,33 @@ const ImaDaiPlugin = function(player, options) {
/**
* Returns the instance of the StreamManager.
* @return {google.ima.StreamManager} The StreamManager being used by the plugin.
* @return {google.ima.StreamManager} The StreamManager being used by the
* plugin.
*/
this.getStreamManager = function() {
return this.controller.getStreamManager();
}.bind(this);
}
};
/**
* Initializes the plugin for client-side ads.
* @param {Object} options Plugin option set on initiation.
*/
const init = function(options) {
/* eslint no-invalid-this: 'off' */
this.ima = new ImaPlugin(this, options);
};
/**
* LiveStream class used for DAI live streams.
*/
class LiveStream {
/**
* LiveStream class constructor used for DAI live streams.
* @param {string} streamFormat stream format, plugin currently supports only
* 'hls' streams.
* @param {string} assetKey live stream's asset key.
*/
constructor(streamFormat, assetKey) {
streamFormat = streamFormat.toLowerCase();
if (streamFormat !== 'hls' && streamFormat !== 'dash') {
@ -278,7 +290,17 @@ class LiveStream {
}
}
/**
* VodStream class used for DAI VOD streams.
*/
class VodStream {
/**
* VodStream class constructor used for DAI VOD streams.
* @param {string} streamFormat stream format, plugin currently supports only
* 'hls' streams.
* @param {string} cmsId VOD stream's CMS ID.
* @param {string} videoId VOD stream's video ID.
*/
constructor(streamFormat, cmsId, videoId) {
streamFormat = streamFormat.toLowerCase();
if (streamFormat !== 'hls' && streamFormat !== 'dash') {
@ -291,7 +313,7 @@ class VodStream {
} else if (typeof cmsId !== 'string') {
window.console.error('cmsId error: value must be string.');
return;
} else if(typeof videoId !== 'string') {
} else if (typeof videoId !== 'string') {
window.console.error('videoId error: value must be string.');
return;
}
@ -302,6 +324,12 @@ class VodStream {
}
}
/**
* Initializes the plugin for DAI ads.
* @param {Object} stream Accepts either an instance of the LiveStream or
* VodStream classes.
* @param {Object} options Plugin option set on initiation.
*/
const initDai = function(stream, options) {
if (stream instanceof LiveStream) {
options.streamType = 'live';
@ -311,7 +339,9 @@ const initDai = function(stream, options) {
options.cmsId = stream.cmsId;
options.videoId = stream.videoId;
} else {
window.console.error('initDai() first parameter must be an instance of LiveStream or VodStream.');
window.console.error(
'initDai() first parameter must be an instance of LiveStream or ' +
'VodStream.');
return;
}
@ -327,5 +357,5 @@ registerPlugin('imaDai', initDai);
export default ImaPlugin;
export {
VodStream,
LiveStream
}
LiveStream,
};