silvermine / videojs-chromecast

MIT License
147 stars 74 forks source link

fix: Clear the close session timeout after new source starts playing #164

Closed izkmdz closed 11 months ago

izkmdz commented 11 months ago

Fixes bug where castSession is null when calling castSession.loadMedia()

When the ChromeCast player state reaches an IDLE state, a timeout will start to close the session after SESSION_TIMEOUT (default is 10 seconds) has elapsed.

After calling _playSource() this close session timeout is cleared. However, when playing a new source, the player state will go from PAUSEDIDLEBUFFERINGPLAYING.

There is a listener for the IDLE state that starts the close session timeout. With the current order of player state changes, this could cause the casting session to close while the new source is being played, even if we are in the PLAYING state.

To prevent this from occurring, we can clear the session timeout when castSession.loadMedia() finishes.

coveralls commented 11 months ago

Coverage Status

coverage: 2.652% (-0.005%) from 2.657% when pulling 4a8eb31faa241235c54c1f8dec897571360e7f19 on izkmdz:cast-session-null-reference-fix into d7e3c99034f6565b1c9e703b3f34235afb6c5b1e on silvermine:master.

yokuze commented 11 months ago

Good find! Thanks @izkmdz