Skip to content

Commit

Permalink
fix: Clear the close session timeout after new source starts playing
Browse files Browse the repository at this point in the history
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
`PAUSED` → `IDLE` → `BUFFERING` → `PLAYING`.

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.
  • Loading branch information
izkmdz committed Aug 4, 2023
1 parent d7e3c99 commit 4a8eb31
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/js/tech/ChromecastTech.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ module.exports = function(videojs) {
this._hasPlayedCurrentItem = false;
castSession.loadMedia(request)
.then(function() {
this._clearSessionTimeout();
if (!this._hasPlayedAnyItem) {
// `triggerReady` is required here to notify the Video.js
// player that the Tech has been initialized and is ready.
Expand Down

0 comments on commit 4a8eb31

Please sign in to comment.