Skip to content

Commit

Permalink
Merge pull request #1 from heff/bugfix/src-getter
Browse files Browse the repository at this point in the history
Made the src method return the player when setting
  • Loading branch information
dmlap committed Mar 4, 2014
2 parents 7184cb4 + e9da335 commit f155814
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {*}
Expand Down
6 changes: 4 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1073,7 +1074,8 @@ vjs.Player.prototype.src = function(source){
}
}
}
return source;

return this;
};

// Begin loading the src data
Expand Down
15 changes: 7 additions & 8 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

notEqual(src, player, 'the player is not returned');
equal('string', typeof src, 'a URL is returned');
test('should return the player when setting src', function() {
var player, ret;

player = PlayerTest.makePlayer({}),
ret = player.src('foo');

equal(player, ret, 'the player is returned');
});

test('should register players with generated ids', function(){
Expand Down

0 comments on commit f155814

Please sign in to comment.