Skip to content

Commit

Permalink
Add a very basic played() method
Browse files Browse the repository at this point in the history
Expose the played attribute on the HTML5 tech. Add a default implementation of played() to the base tech that tracks whether the video has played at all but doesn't provide valid ranges.
  • Loading branch information
dmlap committed Jul 20, 2015
1 parent ca5103b commit f839478
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 60 deletions.
129 changes: 69 additions & 60 deletions src/js/tech/html5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file html5.js
* @file html5.js
* HTML5 Media Controller - Wrapper for HTML5 Media API
*/

Expand Down Expand Up @@ -199,23 +199,23 @@ class Html5 extends Tech {
/**
* Paused for html5 tech
*
* @return {Boolean}
* @return {Boolean}
* @method paused
*/
paused() { return this.el_.paused; }

/**
* Get current time
*
* @return {Number}
* @return {Number}
* @method currentTime
*/
currentTime() { return this.el_.currentTime; }

/**
* Set current time
*
* @param {Number} seconds Current time of video
* @param {Number} seconds Current time of video
* @method setCurrentTime
*/
setCurrentTime(seconds) {
Expand Down Expand Up @@ -246,57 +246,57 @@ class Html5 extends Tech {
buffered() { return this.el_.buffered; }

/**
* Get volume level
* Get volume level
*
* @return {Number}
* @method volume
*/
volume() { return this.el_.volume; }

/**
* Set volume level
* Set volume level
*
* @param {Number} percentAsDecimal Volume percent as a decimal
* @method setVolume
*/
setVolume(percentAsDecimal) { this.el_.volume = percentAsDecimal; }

/**
* Get if muted
* Get if muted
*
* @return {Boolean}
* @method muted
*/
muted() { return this.el_.muted; }

/**
* Set muted
* Set muted
*
* @param {Boolean} If player is to be muted or note
* @method setMuted
*/
setMuted(muted) { this.el_.muted = muted; }

/**
* Get player width
* Get player width
*
* @return {Number}
* @method width
*/
width() { return this.el_.offsetWidth; }

/**
* Get player height
* Get player height
*
* @return {Number}
* @method height
*/
height() { return this.el_.offsetHeight; }

/**
* Get if there is fullscreen support
* Get if there is fullscreen support
*
* @return {Boolean}
* @return {Boolean}
* @method supportsFullScreen
*/
supportsFullScreen() {
Expand Down Expand Up @@ -356,8 +356,8 @@ class Html5 extends Tech {
/**
* Get/set video
*
* @param {Object=} src Source object
* @return {Object}
* @param {Object=} src Source object
* @return {Object}
* @method src
*/
src(src) {
Expand All @@ -372,7 +372,7 @@ class Html5 extends Tech {
/**
* Set video
*
* @param {Object} src Source object
* @param {Object} src Source object
* @deprecated
* @method setSrc
*/
Expand All @@ -386,147 +386,156 @@ class Html5 extends Tech {
load(){ this.el_.load(); }

/**
* Get current source
* Get current source
*
* @return {Object}
* @return {Object}
* @method currentSrc
*/
currentSrc() { return this.el_.currentSrc; }

/**
* Get poster
* Get poster
*
* @return {String}
* @return {String}
* @method poster
*/
poster() { return this.el_.poster; }

/**
* Set poster
* Set poster
*
* @param {String} val URL to poster image
* @method
* @method
*/
setPoster(val) { this.el_.poster = val; }

/**
* Get preload attribute
* Get preload attribute
*
* @return {String}
* @return {String}
* @method preload
*/
preload() { return this.el_.preload; }

/**
* Set preload attribute
* Set preload attribute
*
* @param {String} val Value for preload attribute
* @param {String} val Value for preload attribute
* @method setPreload
*/
setPreload(val) { this.el_.preload = val; }

/**
* Get autoplay attribute
* Get autoplay attribute
*
* @return {String}
* @return {String}
* @method autoplay
*/
autoplay() { return this.el_.autoplay; }

/**
* Set autoplay attribute
* Set autoplay attribute
*
* @param {String} val Value for preload attribute
* @param {String} val Value for preload attribute
* @method setAutoplay
*/
setAutoplay(val) { this.el_.autoplay = val; }

/**
* Get controls attribute
* Get controls attribute
*
* @return {String}
* @return {String}
* @method controls
*/
controls() { return this.el_.controls; }

/**
* Set controls attribute
* Set controls attribute
*
* @param {String} val Value for controls attribute
* @param {String} val Value for controls attribute
* @method setControls
*/
setControls(val) { this.el_.controls = !!val; }

/**
* Get loop attribute
* Get loop attribute
*
* @return {String}
* @return {String}
* @method loop
*/
loop() { return this.el_.loop; }

/**
* Set loop attribute
* Set loop attribute
*
* @param {String} val Value for loop attribute
* @param {String} val Value for loop attribute
* @method setLoop
*/
setLoop(val) { this.el_.loop = val; }

/**
* Get error value
* Get error value
*
* @return {String}
* @return {String}
* @method error
*/
error() { return this.el_.error; }

/**
* Get whether or not the player is in the "seeking" state
*
* @return {Boolean}
* @return {Boolean}
* @method seeking
*/
seeking() { return this.el_.seeking; }

/**
* Get a TimeRanges object that represents the
* ranges of the media resource to which it is possible
* for the user agent to seek.
* Get a TimeRanges object that represents the
* ranges of the media resource to which it is possible
* for the user agent to seek.
*
* @return {TimeRangeObject}
* @return {TimeRangeObject}
* @method seekable
*/
seekable() { return this.el_.seekable; }

/**
* Get if video ended
* Get if video ended
*
* @return {Boolean}
* @return {Boolean}
* @method ended
*/
ended() { return this.el_.ended; }

/**
* Get the value of the muted content attribute
* This attribute has no dynamic effect, it only
* This attribute has no dynamic effect, it only
* controls the default state of the element
*
* @return {Boolean}
* @return {Boolean}
* @method defaultMuted
*/
defaultMuted() { return this.el_.defaultMuted; }

/**
* Get desired speed at which the media resource is to play
* Get desired speed at which the media resource is to play
*
* @return {Number}
* @method playbackRate
*/
playbackRate() { return this.el_.playbackRate; }

/**
* Set desired speed at which the media resource is to play
* Returns a TimeRanges object that represents the ranges of the
* media resource that the user agent has played.
* @return {TimeRangeObject} the range of points on the media
* timeline that has been reached through normal playback
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
*/
played() { return this.el_.played; }

/**
* Set desired speed at which the media resource is to play
*
* @param {Number} val Speed at which the media resource is to play
* @method setPlaybackRate
Expand All @@ -547,40 +556,40 @@ class Html5 extends Tech {
networkState() { return this.el_.networkState; }

/**
* Get a value that expresses the current state of the element
* with respect to rendering the current playback position, from
* Get a value that expresses the current state of the element
* with respect to rendering the current playback position, from
* the codes in the list below
* HAVE_NOTHING (numeric value 0)
* HAVE_METADATA (numeric value 1)
* HAVE_CURRENT_DATA (numeric value 2)
* HAVE_FUTURE_DATA (numeric value 3)
* HAVE_ENOUGH_DATA (numeric value 4)
*
*
* @return {Number}
* @method readyState
*/
readyState() { return this.el_.readyState; }

/**
* Get width of video
* Get width of video
*
* @return {Number}
* @method videoWidth
*/
videoWidth() { return this.el_.videoWidth; }

/**
* Get height of video
* Get height of video
*
* @return {Number}
* @method videoHeight
*/
videoHeight() { return this.el_.videoHeight; }

/**
* Get text tracks
* Get text tracks
*
* @return {TextTrackList}
* @return {TextTrackList}
* @method textTracks
*/
textTracks() {
Expand All @@ -592,7 +601,7 @@ class Html5 extends Tech {
}

/**
* Creates and returns a text track object
* Creates and returns a text track object
*
* @param {String} kind Text track kind (subtitles, captions, descriptions
* chapters and metadata)
Expand All @@ -610,7 +619,7 @@ class Html5 extends Tech {
}

/**
* Creates and returns a remote text track object
* Creates and returns a remote text track object
*
* @param {Object} options The object should contain values for
* kind, language, label and src (location of the WebVTT file)
Expand Down Expand Up @@ -669,7 +678,7 @@ class Html5 extends Tech {
}

/**
* Remove remote text track from TextTrackList object
* Remove remote text track from TextTrackList object
*
* @param {TextTrackObject} track Texttrack object to remove
* @method removeRemoteTextTrack
Expand Down
Loading

0 comments on commit f839478

Please sign in to comment.