diff --git a/src/js/media/flash.js b/src/js/media/flash.js index 7b9dd70536..0d5dccdcfd 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -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 }; diff --git a/src/js/media/html5.js b/src/js/media/html5.js index 66fcdb1586..776c26c710 100644 --- a/src/js/media/html5.js +++ b/src/js/media/html5.js @@ -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; }; diff --git a/src/js/player.js b/src/js/player.js index 64af7acae1..2aa55cc4be 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -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. @@ -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 * @@ -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'); },