mirror of
https://github.com/videojs/video.js.git
synced 2025-02-02 11:34:50 +02:00
Merge branch 'feature/duration-cacheing'
This commit is contained in:
commit
048b808153
@ -1,3 +1,4 @@
|
|||||||
|
* Duration is now setable (need ed for HLS m3u8 files)
|
||||||
* Event binders (on/off/one) now return the player instance
|
* Event binders (on/off/one) now return the player instance
|
||||||
* Stopped player from going back to beginningg on ended event.
|
* Stopped player from going back to beginningg on ended event.
|
||||||
* Added support for percent width/height and fluid layouts
|
* Added support for percent width/height and fluid layouts
|
||||||
|
@ -75,6 +75,7 @@ _V_.Player = _V_.Component.extend({
|
|||||||
this.on("play", this.onPlay);
|
this.on("play", this.onPlay);
|
||||||
this.on("pause", this.onPause);
|
this.on("pause", this.onPause);
|
||||||
this.on("progress", this.onProgress);
|
this.on("progress", this.onProgress);
|
||||||
|
this.on("durationchange", this.onDurationChange);
|
||||||
this.on("error", this.onError);
|
this.on("error", this.onError);
|
||||||
|
|
||||||
// When the API is ready, loop through the components and add to the player.
|
// When the API is ready, loop through the components and add to the player.
|
||||||
@ -358,6 +359,12 @@ _V_.Player = _V_.Component.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Update duration with durationchange event
|
||||||
|
// Allows for cacheing value instead of asking player each time.
|
||||||
|
onDurationChange: function(){
|
||||||
|
this.duration(this.techGet("duration"));
|
||||||
|
},
|
||||||
|
|
||||||
onError: function(e) {
|
onError: function(e) {
|
||||||
_V_.log("Video Error", e);
|
_V_.log("Video Error", e);
|
||||||
},
|
},
|
||||||
@ -470,8 +477,16 @@ _V_.Player = _V_.Component.extend({
|
|||||||
|
|
||||||
// http://dev.w3.org/html5/spec/video.html#dom-media-duration
|
// http://dev.w3.org/html5/spec/video.html#dom-media-duration
|
||||||
// Duration should return NaN if not available. ParseFloat will turn false-ish values to NaN.
|
// Duration should return NaN if not available. ParseFloat will turn false-ish values to NaN.
|
||||||
duration: function(){
|
duration: function(seconds){
|
||||||
return parseFloat(this.techGet("duration"));
|
if (seconds !== undefined) {
|
||||||
|
|
||||||
|
// Cache the last set value for optimiized scrubbing (esp. Flash)
|
||||||
|
this.values.duration = parseFloat(seconds);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.values.duration;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Calculates how much time is left. Not in spec, but useful.
|
// Calculates how much time is left. Not in spec, but useful.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user