1
0
mirror of https://github.com/videojs/video.js.git synced 2025-02-02 11:34:50 +02:00

Made the src method return the player when setting, and made Flash return the current srouce for flash.src()

This commit is contained in:
Steve Heffernan 2014-02-27 17:34:01 -08:00
parent 7184cb4b49
commit e9da3350d4
3 changed files with 17 additions and 13 deletions

View File

@ -243,12 +243,15 @@ vjs.Flash.prototype.pause = function(){
};
vjs.Flash.prototype.src = function(src){
if (src === undefined) {
return this.currentSrc();
}
if (vjs.Flash.isStreamingSrc(src)) {
src = vjs.Flash.streamToParts(src);
this.setRtmpConnection(src.connection);
this.setRtmpStream(src.stream);
}
else {
} else {
// Make sure source URL is abosolute.
src = vjs.getAbsoluteURL(src);
this.el_.vjs_src(src);
@ -303,8 +306,8 @@ vjs.Flash.prototype.enterFullScreen = function(){
// Create setters and getters for attributes
var api = vjs.Flash.prototype,
readWrite = 'rtmpConnection,rtmpStream,preload,currentTime,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(','),
readOnly = 'error,currentSrc,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks'.split(',');
// Overridden: buffered
readOnly = 'error,networkState,readyState,seeking,initialTime,duration,startOffsetTime,paused,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks'.split(',');
// Overridden: buffered, currentSrc
/**
* @this {*}

View File

@ -1014,7 +1014,8 @@ vjs.Player.prototype.selectSource = function(sources){
* ]);
*
* @param {String|Object|Array=} source The source URL, object, or array of sources
* @return {String} The current video source
* @return {String} The current video source when getting
* @return {String} The player when setting
*/
vjs.Player.prototype.src = function(source){
if (source === undefined) {
@ -1073,7 +1074,8 @@ vjs.Player.prototype.src = function(source){
}
}
}
return source;
return this;
};
// Begin loading the src data

View File

@ -357,14 +357,13 @@ test('should use custom message when encountering an unsupported video type',
player.dispose();
});
test('should delegate to the tech for src accesses', function() {
var
player = PlayerTest.makePlayer({}),
src;
src = player.src();
test('should return the player when setting src', function() {
var player, ret;
notEqual(src, player, 'the player is not returned');
equal('string', typeof src, 'a URL is returned');
player = PlayerTest.makePlayer({}),
ret = player.src('foo');
equal(player, ret, 'the player is returned');
});
test('should register players with generated ids', function(){