@@ -170,6 +170,9 @@ shaka.text.UITextDisplayer = class {
170170 this . cues_ . push ( cue ) ;
171171 }
172172 }
173+ if ( this . cues_ . length ) {
174+ this . configureCaptionsTimer_ ( ) ;
175+ }
173176
174177 this . updateCaptions_ ( ) ;
175178 }
@@ -232,6 +235,9 @@ shaka.text.UITextDisplayer = class {
232235 // displaying if removed (say, due to the user changing languages).
233236 const forceUpdate = oldNumCues > this . cues_ . length ;
234237 this . updateCaptions_ ( forceUpdate ) ;
238+ if ( ! this . cues_ . length ) {
239+ this . configureCaptionsTimer_ ( ) ;
240+ }
235241
236242 return true ;
237243 }
@@ -259,11 +265,15 @@ shaka.text.UITextDisplayer = class {
259265 */
260266 configureCaptionsTimer_ ( ) {
261267 if ( this . captionsTimer_ ) {
262- const captionsUpdatePeriod = this . config_ ?
263- this . config_ . captionsUpdatePeriod : 0.25 ;
264- const updateTime = captionsUpdatePeriod /
265- Math . max ( 1 , Math . abs ( this . video_ . playbackRate ) ) ;
266- this . captionsTimer_ . tickEvery ( updateTime ) ;
268+ if ( this . cues_ . length ) {
269+ const captionsUpdatePeriod = this . config_ ?
270+ this . config_ . captionsUpdatePeriod : 0.25 ;
271+ const updateTime = captionsUpdatePeriod /
272+ Math . max ( 1 , Math . abs ( this . video_ . playbackRate ) ) ;
273+ this . captionsTimer_ . tickEvery ( updateTime ) ;
274+ } else {
275+ this . captionsTimer_ . stop ( ) ;
276+ }
267277 }
268278 }
269279
0 commit comments