Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video does not resume playing in browser after disconnecting from chromecast #174

Open
ToshY opened this issue Jan 6, 2024 · 0 comments

Comments

@ToshY
Copy link

ToshY commented Jan 6, 2024

Problem

When a video is playing on chromecast, and the chromecast is disconnected, the video is paused even though it should be playing according to _reloadTech.

Expected

Video should resume playing in browser if it was playing on the chromecast after disconnecting.

Reproduction

  1. Go to example: https://codepen.io/nanone/pen/jOJqyBq
  2. Cast the video to chromecast.
  3. Do not pause the video, and disconnect the chromecast.
  4. The video is now paused even though it should be playing.

Possible solutions

I've been debugging this, and if I put a player.load() inside the ready function, it seems to work.

   _reloadTech() {
      var player = this.player,
          currentTime = player.currentTime(),
          wasPaused = player.paused(),
          sources = player.currentSources();

      // Reload the current source(s) to re-lookup and use the currently available Tech.
      // The chromecast Tech gets used if `ChromecastSessionManager.isChromecastConnected`
      // is true (effectively, if a chromecast session is currently in progress),
      // otherwise Video.js continues to search through the Tech list for other eligible
      // Tech to use, such as the HTML5 player.
      player.src(sources);

      player.ready(function() {
         player.load(); // added this
         if (wasPaused) {
            player.pause();
         } else {
            player.play();
         }
         player.currentTime(currentTime || 0);
      });
   }

Please let me know if this is a OK solution, I will create a PR for it.

Versions
videojs: 8.9.0
silvermine/videojs-chromecast: 1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant