File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed
control-bar/time-controls Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ class DurationDisplay extends TimeDisplay {
28
28
// it has changed
29
29
this . on ( player , 'durationchange' , this . updateContent ) ;
30
30
31
+ // Listen to loadstart because the player duration is reset when a new media element is loaded,
32
+ // but the durationchange on the user agent will not fire.
33
+ // @see [Spec]{@link https://www.w3.org/TR/2011/WD-html5-20110113/video.html#media-element-load-algorithm}
34
+ this . on ( player , 'loadstart' , this . updateContent ) ;
35
+
31
36
// Also listen for timeupdate (in the parent) and loadedmetadata because removing those
32
37
// listeners could have broken dependent applications/libraries. These
33
38
// can likely be removed for 7.0.
@@ -58,7 +63,7 @@ class DurationDisplay extends TimeDisplay {
58
63
updateContent ( event ) {
59
64
const duration = this . player_ . duration ( ) ;
60
65
61
- if ( duration && this . duration_ !== duration ) {
66
+ if ( this . duration_ !== duration ) {
62
67
this . duration_ = duration ;
63
68
this . updateFormattedTime_ ( duration ) ;
64
69
}
Original file line number Diff line number Diff line change @@ -1290,6 +1290,9 @@ class Player extends Component {
1290
1290
// reset the error state
1291
1291
this . error ( null ) ;
1292
1292
1293
+ // Update the duration
1294
+ this . handleTechDurationChange_ ( ) ;
1295
+
1293
1296
// If it's already playing we want to trigger a firstplay event now.
1294
1297
// The firstplay event relies on both the play and loadstart events
1295
1298
// which can happen in any order for a new source
@@ -2288,11 +2291,16 @@ class Player extends Component {
2288
2291
} else {
2289
2292
this . removeClass ( 'vjs-live' ) ;
2290
2293
}
2291
- /**
2292
- * @event Player#durationchange
2293
- * @type {EventTarget~Event }
2294
- */
2295
- this . trigger ( 'durationchange' ) ;
2294
+ if ( ! isNaN ( seconds ) ) {
2295
+ // Do not fire durationchange unless the duration value is known.
2296
+ // @see [Spec]{@link https://www.w3.org/TR/2011/WD-html5-20110113/video.html#media-element-load-algorithm}
2297
+
2298
+ /**
2299
+ * @event Player#durationchange
2300
+ * @type {EventTarget~Event }
2301
+ */
2302
+ this . trigger ( 'durationchange' ) ;
2303
+ }
2296
2304
}
2297
2305
}
2298
2306
You can’t perform that action at this time.
0 commit comments