1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-14 11:23:30 +02:00
video.js/test/unit/mediafaker.js
David LaPalomento 7184cb4b49 src() called as a getter should return the video src
It can be handy that src() returns the player object when it is invoked but it does not match the behavior of the corresponding property on the video element. Ignoring the spec however, while the video element is running the resource selection algorithm, currentSrc may be undefined. If the video source has been specified through an attribute on the video element, src() is the natural way to expose that URL programmatically. Without this change, it's necessary to bypass the player and interact with the tech directly to determine the value of the src attribute.
2014-01-25 23:16:35 -05:00

52 lines
1.8 KiB
JavaScript

// Fake a media playback tech controller so that player tests
// can run without HTML5 or Flash, of which PhantomJS supports neither.
/**
* @constructor
*/
vjs.MediaFaker = vjs.MediaTechController.extend({
init: function(player, options, onReady){
vjs.MediaTechController.call(this, player, options, onReady);
this.triggerReady();
}
});
// Support everything
vjs.MediaFaker.isSupported = function(){ return true; };
vjs.MediaFaker.canPlaySource = function(srcObj){ return true; };
vjs.MediaFaker.prototype.createEl = function(){
var el = vjs.MediaTechController.prototype.createEl.call(this, 'div', {
className: 'vjs-tech'
});
if (this.player().poster()) {
// transfer the poster image to mimic HTML
el.poster = this.player().poster();
}
vjs.insertFirst(el, this.player_.el());
return el;
};
// fake a poster attribute to mimic the video element
vjs.MediaFaker.prototype.poster = function(){ return this.el().poster; };
vjs.MediaFaker.prototype['setPoster'] = function(val){ this.el().poster = val; };
vjs.MediaFaker.prototype.currentTime = function(){ return 0; };
vjs.MediaFaker.prototype.seeking = function(){ return false; };
vjs.MediaFaker.prototype.src = function(){ return 'movie.mp4'; };
vjs.MediaFaker.prototype.volume = function(){ return 0; };
vjs.MediaFaker.prototype.muted = function(){ return false; };
vjs.MediaFaker.prototype.pause = function(){ return false; };
vjs.MediaFaker.prototype.supportsFullScreen = function(){ return false; };
vjs.MediaFaker.prototype.features = {};
vjs.MediaFaker.prototype.buffered = function(){ return {}; };
vjs.MediaFaker.prototype.duration = function(){ return {}; };
// Export vars for Closure Compiler
vjs['MediaFaker'] = vjs.MediaFaker;
vjs['MediaFaker']['isSupported'] = vjs.MediaFaker.isSupported;
vjs['MediaFaker']['canPlaySource'] = vjs.MediaFaker.canPlaySource;