2013-01-26 04:36:40 +03:00
|
|
|
// Fake a media playback tech controller so that player tests
|
2013-01-18 04:33:53 +03:00
|
|
|
// can run without HTML5 or Flash, of which PhantomJS supports neither.
|
2015-05-04 01:12:38 +02:00
|
|
|
import Tech from '../../../src/js/tech/tech.js';
|
2015-03-11 03:01:11 +02:00
|
|
|
|
2013-01-26 04:36:40 +03:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
2015-05-04 01:12:38 +02:00
|
|
|
class TechFaker extends Tech {
|
2013-01-18 04:33:53 +03:00
|
|
|
|
2016-08-03 21:27:03 +02:00
|
|
|
constructor(options, handleReady) {
|
2015-05-06 20:01:52 +02:00
|
|
|
super(options, handleReady);
|
2017-03-02 21:35:45 +02:00
|
|
|
if (!options || options.autoReady !== false) {
|
|
|
|
this.triggerReady();
|
|
|
|
}
|
2013-04-09 23:43:35 +03:00
|
|
|
}
|
2015-04-14 22:08:32 +02:00
|
|
|
|
|
|
|
createEl() {
|
2016-08-03 21:27:03 +02:00
|
|
|
const el = super.createEl('div', {
|
2015-04-14 22:08:32 +02:00
|
|
|
className: 'vjs-tech'
|
|
|
|
});
|
|
|
|
|
|
|
|
return el;
|
2013-04-04 16:55:27 +03:00
|
|
|
}
|
2013-01-18 04:33:53 +03:00
|
|
|
|
2015-04-14 22:08:32 +02:00
|
|
|
// fake a poster attribute to mimic the video element
|
2016-08-03 21:27:03 +02:00
|
|
|
poster() {
|
|
|
|
return this.el().poster;
|
|
|
|
}
|
|
|
|
setPoster(val) {
|
|
|
|
this.el().poster = val;
|
2018-03-07 21:31:50 +02:00
|
|
|
this.trigger('posterchange');
|
2016-08-03 21:27:03 +02:00
|
|
|
}
|
2015-04-14 22:08:32 +02:00
|
|
|
|
2015-05-06 20:01:52 +02:00
|
|
|
setControls(val) {}
|
|
|
|
|
feat: middleware (#3788)
Add middleware support. Middleware can function as go-between between the player and the tech. For example, it can modify the duration that the tech returns to the player. In addition, middleware allow for supporting custom video sources and types.
Currently, middleware can only intercept timeline methods like duration, currentTime, and setCurrentTime.
For example,
```js
videojs.use('video/foo', {
setSource(src, next) {
next(null, {
src: 'http://example.com/video.mp4',
type: 'video/mp4'
});
}
});
```
Will allow you to set a source with type `video/foo` which will play back `video.mp4`.
This makes setting the source asynchronous, which aligns it with the spec a bit more. Methods like play can still be called synchronously on the player after setting the source and the player will play once the source has loaded.
`sourceOrder` option was removed as well and it will now always use source ordering.
BREAKING CHANGE: setting the source is now asynchronous. `sourceOrder` option removed and made the default.
2017-01-20 00:29:09 +02:00
|
|
|
setVolume(newVolume) {}
|
|
|
|
|
2017-02-01 00:15:56 +02:00
|
|
|
setMuted() {}
|
|
|
|
|
2017-12-14 18:24:48 +02:00
|
|
|
setAutoplay() {}
|
|
|
|
|
2016-08-03 21:27:03 +02:00
|
|
|
currentTime() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
seeking() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
src() {
|
|
|
|
return 'movie.mp4';
|
|
|
|
}
|
2016-11-03 21:50:55 +02:00
|
|
|
currentSrc() {
|
|
|
|
return 'movie.mp4';
|
|
|
|
}
|
2016-08-03 21:27:03 +02:00
|
|
|
volume() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
muted() {
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-14 18:24:48 +02:00
|
|
|
autoplay() {
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-03 21:27:03 +02:00
|
|
|
pause() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
paused() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-01-30 18:30:42 +02:00
|
|
|
loop() {
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-03 21:27:03 +02:00
|
|
|
play() {
|
|
|
|
this.trigger('play');
|
|
|
|
}
|
|
|
|
supportsFullScreen() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
buffered() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
duration() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
networkState() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
readyState() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
controls() {
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-14 22:08:32 +02:00
|
|
|
|
|
|
|
// Support everything except for "video/unsupported-format"
|
2016-08-03 21:27:03 +02:00
|
|
|
static isSupported() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
static canPlayType(type) {
|
|
|
|
return (type !== 'video/unsupported-format' ? 'maybe' : '');
|
|
|
|
}
|
|
|
|
static canPlaySource(srcObj) {
|
|
|
|
return srcObj.type !== 'video/unsupported-format';
|
|
|
|
}
|
2015-04-14 22:08:32 +02:00
|
|
|
}
|
2015-03-26 06:43:41 +02:00
|
|
|
|
2015-11-10 22:53:14 +02:00
|
|
|
Tech.registerTech('TechFaker', TechFaker);
|
2015-05-04 01:12:38 +02:00
|
|
|
export default TechFaker;
|