mirror of
https://github.com/videojs/video.js.git
synced 2024-12-14 11:23:30 +02:00
a2b1a33606
Previously timeupdate would fire before the video was playing, and the tech was not ready. This caused issues when preload was set to auto, because cuechange would fire before the video was even started for cues with a startTime of 0. Wait for tech to be ready before watching for timeupdate update unit tests to use TechFaker Add a unit test to verify that we wait for Tech to be ready.
99 lines
1.6 KiB
JavaScript
99 lines
1.6 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;
|
|
}
|
|
|
|
setControls(val) {}
|
|
|
|
setVolume(newVolume) {}
|
|
|
|
setMuted() {}
|
|
|
|
currentTime() {
|
|
return 0;
|
|
}
|
|
seeking() {
|
|
return false;
|
|
}
|
|
src() {
|
|
return 'movie.mp4';
|
|
}
|
|
currentSrc() {
|
|
return 'movie.mp4';
|
|
}
|
|
volume() {
|
|
return 0;
|
|
}
|
|
muted() {
|
|
return false;
|
|
}
|
|
pause() {
|
|
return false;
|
|
}
|
|
paused() {
|
|
return true;
|
|
}
|
|
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;
|