Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
if (options.startTime) {
this.ready(function(){
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
window.videojs = window.videojs || {};
window.videojs.Flash = window.videojs.Flash || {};
window.videojs.Flash.onReady = Flash.onReady;
window.videojs.Flash.onEvent = Flash.onEvent;
window.videojs.Flash.onError = Flash.onError;
this.on('seeked', function() {
this.lastSeekTarget_ = undefined;
});
}
// Having issues with Flash reloading on certain page actions
// (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
if (options.startTime) {
this.ready(function() {
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
window.videojs = window.videojs || {};
window.videojs.Flash = window.videojs.Flash || {};
window.videojs.Flash.onReady = Flash.onReady;
window.videojs.Flash.onEvent = Flash.onEvent;
window.videojs.Flash.onError = Flash.onError;
this.on('seeked', function() {
this.lastSeekTarget_ = undefined;
});
}
// Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
if (options.startTime) {
this.ready(function() {
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
window.videojs = window.videojs || {};
window.videojs.Flash = window.videojs.Flash || {};
window.videojs.Flash.onReady = Flash.onReady;
window.videojs.Flash.onEvent = Flash.onEvent;
window.videojs.Flash.onError = Flash.onError;
this.on('seeked', function() {
this.lastSeekTarget_ = undefined;
});
}
this.ready(function() {
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
window.videojs = window.videojs || {};
window.videojs.Flash = window.videojs.Flash || {};
window.videojs.Flash.onReady = Flash.onReady;
window.videojs.Flash.onEvent = Flash.onEvent;
window.videojs.Flash.onError = Flash.onError;
this.on('seeked', function() {
this.lastSeekTarget_ = undefined;
});
// calling into the SWF can be expensive, especially if Flash is
// busy rendering video frames
// automatically cache commonly used properties for a short period
// of time so that multiple calls within a short time period don't
// all pay a big performance penalty for properties that change
// relatively slowly over time
const getCurrentTimeCached = timeExpiringCache(() => {
return this.el_.vjs_getProperty('currentTime');
}, 100);
this.currentTime = (time) => {
// (hide/resize/fullscreen) in certain browsers
// This allows resetting the playhead when we catch the reload
if (options.startTime) {
this.ready(function() {
this.load();
this.play();
this.currentTime(options.startTime);
}, true);
}
// Add global window functions that the swf expects
// A 4.x workflow we weren't able to solve for in 5.0
// because of the need to hard code these functions
// into the swf for security reasons
window.videojs = window.videojs || {};
window.videojs.Flash = window.videojs.Flash || {};
window.videojs.Flash.onReady = Flash.onReady;
window.videojs.Flash.onEvent = Flash.onEvent;
window.videojs.Flash.onError = Flash.onError;
this.on('seeked', function() {
this.lastSeekTarget_ = undefined;
});
}
// If no script URL is associated, skip it.
if (!value) {
return;
}
// Find all script elements and remove them.
Array.prototype.slice
.call(document.querySelectorAll(`script[src="${value}"]`))
.forEach(el => el.parentNode.removeChild(el));
});
// Clear the internal cache that have been downloaded.
playerScriptCache.clear();
// Dispose any remaining players from the `videojs` global.
disposeAll(window.videojs);
// There may be other `videojs` instances lurking in the bowels of the
// `bc` global. This should eliminate any of those.
getBcGlobalKeys().forEach(k => disposeAll(window.bc[k].videojs));
// Delete any global object keys that were created.
getGlobalKeys().forEach(k => {
delete window[k];
});
};
QUnit.test('videojs should exist on the window', function(assert) {
assert.ok(window.videojs, 'videojs exists on the window');
});
static getTech(name) {
if (Tech.techs_ && Tech.techs_[name]) {
return Tech.techs_[name];
}
if (window && window.videojs && window.videojs[name]) {
log.warn(`The ${name} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`);
return window.videojs[name];
}
}
}
static getTech(name) {
if (!name) {
return;
}
if (Tech.techs_ && Tech.techs_[name]) {
return Tech.techs_[name];
}
name = toTitleCase(name);
if (window && window.videojs && window.videojs[name]) {
log.warn(`The ${name} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`);
return window.videojs[name];
}
}
}