@@ -120,9 +120,7 @@ VideoRenderer.prototype.initPlayerControls = function() {
120120 if ( this . _boolAutoplay ) {
121121 this . eleVideo . toggleAttribute ( 'autoplay' , true ) ;
122122 }
123- if ( this . _boolLoop ) {
124- this . eleVideo . toggleAttribute ( 'loop' , true ) ;
125- }
123+
126124 if ( this . player . _boolHasPoster ) {
127125 this . eleVideo . setAttribute ( 'poster' , this . player . _loadingPosterURL ) ;
128126 if ( this . player . _boolForcedSize ) {
@@ -169,7 +167,6 @@ VideoRenderer.prototype.initPlayerControls = function() {
169167 if ( self . _boolSingleFrame ) {
170168 self . eleVideo . currentTime = self . _mfBeginT ;
171169 self . _frameNumber = self . _mfBeginF ;
172- // self.processFrame();
173170 }
174171
175172 // so that we see overlay and time stamp now that we are ready
@@ -179,6 +176,37 @@ VideoRenderer.prototype.initPlayerControls = function() {
179176 }
180177 } ) ;
181178
179+ this . eleVideo . addEventListener ( 'ended' , function ( ) {
180+ if ( self . _boolLoop ) {
181+ self . eleVideo . play ( ) ;
182+ } else {
183+ self . _boolPlaying = false ;
184+ self . updateFromDynamicState ( ) ;
185+ }
186+ } ) ;
187+
188+
189+ this . eleVideo . addEventListener ( 'pause' , function ( ) {
190+ self . checkForFragmentReset ( self . computeFrameNumber ( ) ) ;
191+ if ( self . _boolPlaying && ! self . _lockToMF && ! self . _boolManualSeek
192+ && ! self . eleVideo . ended ) {
193+ self . eleVideo . play ( ) ;
194+ }
195+ } ) ;
196+
197+ // Update the seek bar as the video plays
198+ this . eleVideo . addEventListener ( 'timeupdate' , function ( ) {
199+ // Calculate the slider value
200+ const value = ( 100 / self . eleVideo . duration ) * self . eleVideo
201+ . currentTime ;
202+ // Update the slider value
203+ self . eleSeekBar . value = value ;
204+ } ) ;
205+
206+ this . eleVideo . addEventListener ( 'play' , function ( ) {
207+ self . timerCallback ( ) ;
208+ } , false ) ;
209+
182210 this . eleVideoSource . addEventListener ( 'error' , function ( ) {
183211 if ( self . player . _boolNotFound ) {
184212 self . eleVideo . setAttribute ( 'poster' , self . player . _notFoundPosterURL ) ;
@@ -228,31 +256,6 @@ VideoRenderer.prototype.initPlayerControls = function() {
228256 }
229257 } ) ;
230258
231- this . eleVideo . addEventListener ( 'ended' , function ( ) {
232- self . _boolPlaying = false ;
233- self . updateFromDynamicState ( ) ;
234- } ) ;
235-
236- this . eleVideo . addEventListener ( 'pause' , function ( ) {
237- // this is a pause that is fired from the video player itself and not from
238- // the user clicking the play/pause button.
239- // Noting the checkForFragmentReset function calls updateFromDynamicState
240- self . checkForFragmentReset ( self . computeFrameNumber ( ) ) ;
241- } ) ;
242-
243- // Update the seek bar as the video plays
244- this . eleVideo . addEventListener ( 'timeupdate' , function ( ) {
245- // Calculate the slider value
246- const value = ( 100 / self . eleVideo . duration ) * self . eleVideo
247- . currentTime ;
248- // Update the slider value
249- self . eleSeekBar . value = value ;
250- } ) ;
251-
252- this . eleVideo . addEventListener ( 'play' , function ( ) {
253- self . timerCallback ( ) ;
254- } , false ) ;
255-
256259 this . parent . addEventListener ( 'mouseenter' , function ( ) {
257260 // Two different behaviors.
258261 // 1. Regular Mode: show controls.
@@ -360,9 +363,6 @@ VideoRenderer.prototype.updateFromDynamicState = function() {
360363 return ;
361364 }
362365
363- this . eleVideo . toggleAttribute ( 'autoplay' , this . _boolAutoplay ) ;
364- this . eleVideo . toggleAttribute ( 'loop' , this . _boolLoop ) ;
365-
366366 if ( this . _boolPlaying ) {
367367 if ( ! this . _boolSingleFrame ) {
368368 this . eleVideo . play ( ) ;
@@ -423,6 +423,7 @@ VideoRenderer.prototype.updateStateFromTimeChange = function() {
423423 // check if we have a media fragment and should be looping
424424 // if so, reset the playing location appropriately
425425 cfn = this . checkForFragmentReset ( cfn ) ;
426+ this . updateFromDynamicState ( ) ;
426427 if ( cfn !== this . _frameNumber ) {
427428 this . _frameNumber = cfn ;
428429 this . processFrame ( ) ;
@@ -451,6 +452,7 @@ isDataLoaded: ${this._isDataLoaded}
451452overlayCanBePrepared: ${ this . _overlayCanBePrepared }
452453isOverlayPrepared: ${ this . _isOverlayPrepared }
453454isPreparingOverlay: ${ this . _isPreparingOverlay }
455+ hasMediaFragment: ${ this . _hasMediaFragment }
454456` ;
455457} ;
456458
@@ -574,16 +576,13 @@ VideoRenderer.prototype.checkForFragmentReset = function(fn) {
574576 return fn ;
575577 }
576578
577- if ( fn >= this . _mfEndF ) {
579+ if ( fn >= this . _mfEndF || this . eleVideo . ended ) {
578580 if ( this . _boolLoop ) {
579581 this . eleVideo . currentTime = this . _mfBeginT ;
580582 fn = this . _mfBeginF ;
581583 } else {
582584 this . _boolPlaying = false ;
583585 }
584- // Important to only update in here since this is only the case that the
585- // state has changed.
586- this . updateFromDynamicState ( ) ;
587586 }
588587
589588 return fn ;
0 commit comments