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 autoplays after dynamic import #8022

Closed
LuLaValva opened this issue Feb 5, 2025 · 3 comments · Fixed by #8024 · May be fixed by #7962
Closed

Video autoplays after dynamic import #8022

LuLaValva opened this issue Feb 5, 2025 · 3 comments · Fixed by #8024 · May be fixed by #7962
Labels
type: bug Something isn't working correctly
Milestone

Comments

@LuLaValva
Copy link

Have you read the FAQ and checked for duplicate open issues?

  • Yes

If the problem is related to FairPlay, have you read the tutorial?

  • N/A

What version of Shaka Player are you using?

  • Seems like bug was introduced in 4.13.0 and still exists in latest (4.13.2)

Can you reproduce the issue with our latest release version?

  • Yes

Can you reproduce the issue with the latest code from main?

  • Yes

Are you using the demo app or your own custom app?

  • Custom app

If custom app, can you reproduce the issue using our demo app?

  • No

What browser and OS are you using?

  • MacOS, bug exists in Chrome & Safari & Firefox

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

  • N/A

What are the manifest and license server URIs?

  • N/A

What configuration are you using? What is the output of player.getNonDefaultConfiguration()?

  • All default configurations

What did you do?

  • Import shaka-player dynamically, and then attach to a <video> element and load a video

  • Minimal reproduction in this codepen or code below:

    <button onclick="mountShaka('4.13.2')">Mount 4.13.2</button>
    <button onclick="mountShaka('4.12.10')">Mount 4.12.10</button>
    <video id="host"></video>
    
    <script>
      function loadShaka(version) {
        return import(`https://esm.sh/shaka-player@${version}/dist/shaka-player.ui.js`)
      }
      
      function mountShaka(version) {
        loadShaka(version)
          .then(async (shaka) => {
            shaka = shaka.default || shaka;
      
            const player = new shaka.Player();
            await player.attach(host);
          
            player.load("https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd");
          })
      }
    </script>
    

What did you expect to happen?

  • Video loads without playing automatically

What actually happened?

  • Video loaded and immediately started playing

Are you planning to send a PR to fix it?

  • Not unless we can identify exactly what's causing it. The current suspect is this commit
@LuLaValva LuLaValva added the type: bug Something isn't working correctly label Feb 5, 2025
@shaka-bot shaka-bot added this to the v4.14 milestone Feb 5, 2025
@absidue
Copy link

absidue commented Feb 5, 2025

Can confirm we are seeing the same behaviour since updating to 4.13.x the video just starts playing regardless of whether the autoplay attribute is set on the video or not. That commit definitely looks like the culprit as it calls video.play() automatically and there seems to be no way to stop it, we aren't even using cmcd.

@LuLaValva
Copy link
Author

Thanks for the quick response @absidue! Yes, it automatically plays regardless of the autoplay attribute, see the codepen attached.

joeyparrish added a commit to joeyparrish/shaka-player that referenced this issue Feb 5, 2025
b2673fd (shaka-project#7412) introduced a call to video.play() in a function that says "Set
start time of load if autoplay is enabled", but the function did not actually
check the autoplay attribute.  This fixes the oversight.

Fixes shaka-project#8022
@joeyparrish
Copy link
Member

Thanks for finding the culprit commit. I put up #8024, but it is not well tested because I don't have any projects which use dynamic import like your example. Please check and let me know if this fixes the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working correctly
Projects
None yet
4 participants