mirror of
https://github.com/videojs/video.js.git
synced 2024-12-12 11:15:04 +02:00
8706941573
The option for the player techCanOverridePoster is introduced in this commit. It allows techs to update the post whenever they like. isPosterFromTech_ is introduced as a private player field in order to track when a poster was set by a tech. This allows us to clear the poster whenever the tech is disposed of by the player. Additionally, attempting to set the same poster more than once will have no effect / no changes will be made, since the poster is the same. This was done in order to stop triggering multiple posterchange events when calling player.poster(aPoster) with techCanOverridePoster set to true. When a tech is disposed and a poster was set by it, unset the poster. Pass a `canOverridePoster` option to techs to know whether techCanOverridePoster was set. Fixes #4910.
108 lines
1.7 KiB
JavaScript
108 lines
1.7 KiB
JavaScript
// Fake a media playback tech controller so that player tests
|
|
// can run without HTML5 or Flash, of which PhantomJS supports neither.
|
|
import Tech from '../../../src/js/tech/tech.js';
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
class TechFaker extends Tech {
|
|
|
|
constructor(options, handleReady) {
|
|
super(options, handleReady);
|
|
if (!options || options.autoReady !== false) {
|
|
this.triggerReady();
|
|
}
|
|
}
|
|
|
|
createEl() {
|
|
const el = super.createEl('div', {
|
|
className: 'vjs-tech'
|
|
});
|
|
|
|
return el;
|
|
}
|
|
|
|
// fake a poster attribute to mimic the video element
|
|
poster() {
|
|
return this.el().poster;
|
|
}
|
|
setPoster(val) {
|
|
this.el().poster = val;
|
|
this.trigger('posterchange');
|
|
}
|
|
|
|
setControls(val) {}
|
|
|
|
setVolume(newVolume) {}
|
|
|
|
setMuted() {}
|
|
|
|
setAutoplay() {}
|
|
|
|
currentTime() {
|
|
return 0;
|
|
}
|
|
seeking() {
|
|
return false;
|
|
}
|
|
src() {
|
|
return 'movie.mp4';
|
|
}
|
|
currentSrc() {
|
|
return 'movie.mp4';
|
|
}
|
|
volume() {
|
|
return 0;
|
|
}
|
|
muted() {
|
|
return false;
|
|
}
|
|
autoplay() {
|
|
return false;
|
|
}
|
|
pause() {
|
|
return false;
|
|
}
|
|
paused() {
|
|
return true;
|
|
}
|
|
loop() {
|
|
return false;
|
|
}
|
|
play() {
|
|
this.trigger('play');
|
|
}
|
|
supportsFullScreen() {
|
|
return false;
|
|
}
|
|
buffered() {
|
|
return {};
|
|
}
|
|
duration() {
|
|
return {};
|
|
}
|
|
networkState() {
|
|
return 0;
|
|
}
|
|
readyState() {
|
|
return 0;
|
|
}
|
|
controls() {
|
|
return false;
|
|
}
|
|
|
|
// Support everything except for "video/unsupported-format"
|
|
static isSupported() {
|
|
return true;
|
|
}
|
|
static canPlayType(type) {
|
|
return (type !== 'video/unsupported-format' ? 'maybe' : '');
|
|
}
|
|
static canPlaySource(srcObj) {
|
|
return srcObj.type !== 'video/unsupported-format';
|
|
}
|
|
}
|
|
|
|
Tech.registerTech('TechFaker', TechFaker);
|
|
export default TechFaker;
|