Skip to content

Commit

Permalink
Add played property for player
Browse files Browse the repository at this point in the history
  • Loading branch information
brainopia committed Jun 16, 2014
1 parent d09cec8 commit 6d8bf98
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ vjs.Flash.prototype.buffered = function(){
return vjs.createTimeRange(0, this.el_.vjs_getProperty('buffered'));
};

vjs.Flash.prototype.played = function(){
return vjs.createTimeRange(0, this.el_.vjs_getProperty('currentTime'));
};

vjs.Flash.prototype.supportsFullScreen = function(){
return false; // Flash does not allow fullscreen through javascript
};
Expand Down
1 change: 1 addition & 0 deletions src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ vjs.Html5.prototype.setCurrentTime = function(seconds){

vjs.Html5.prototype.duration = function(){ return this.el_.duration || 0; };
vjs.Html5.prototype.buffered = function(){ return this.el_.buffered; };
vjs.Html5.prototype.played = function(){ return this.el_.played; };

vjs.Html5.prototype.volume = function(){ return this.el_.volume; };
vjs.Html5.prototype.setVolume = function(percentAsDecimal){ this.el_.volume = percentAsDecimal; };
Expand Down
19 changes: 17 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ vjs.Player.prototype.remainingTime = function(){
return this.duration() - this.currentTime();
};

// http://dev.w3.org/html5/spec/video.html#dom-media-buffered
// http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#dom-media-buffered
// Buffered returns a timerange object.
// Kind of like an array of portions of the video that have been downloaded.

Expand Down Expand Up @@ -777,6 +777,22 @@ vjs.Player.prototype.buffered = function(){
return buffered;
};

/**
* Get a TimeRange object with the times of the video that have been played.
* http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#dom-media-played
*
* @return {Object} A mock TimeRange object (following HTML spec)
*/
vjs.Player.prototype.played = function(){
var played = this.techGet('played');

if (!played || !played.length) {
played = vjs.createTimeRange(0,this.cache_.currentTime);
}

return played;
};

/**
* Get the percent (as a decimal) of the video that's been downloaded
*
Expand Down Expand Up @@ -1531,7 +1547,6 @@ vjs.Player.prototype.playbackRate = function(rate) {
// readyState: function(){ return this.techCall('readyState'); },
// initialTime: function(){ return this.techCall('initialTime'); },
// startOffsetTime: function(){ return this.techCall('startOffsetTime'); },
// played: function(){ return this.techCall('played'); },
// seekable: function(){ return this.techCall('seekable'); },
// videoTracks: function(){ return this.techCall('videoTracks'); },
// audioTracks: function(){ return this.techCall('audioTracks'); },
Expand Down

0 comments on commit 6d8bf98

Please sign in to comment.