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

YouTube video playback doesn't start when the video is muted #132

Closed
carelevers opened this issue Jun 14, 2024 · 8 comments
Closed

YouTube video playback doesn't start when the video is muted #132

carelevers opened this issue Jun 14, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@carelevers
Copy link

carelevers commented Jun 14, 2024

Describe the bug

When attempting to start playback of a YouTube video while it is muted, the video doesn't start. This issue occurs in chrome or chromium based browsers. It behaves normally in firefox.

Steps to reproduce

The issue also occurs in the provided glitch demo playground : https://glitch.com/edit/#!/vlitejs-youtube-video

However, i noticed this playground runs on vlite-js release 5, so I remixed a glitch environment to vlite-js 6.0.3 where the issue also occurs: https://glitch.com/edit/#!/sage-quilted-hippopotamus

It also works when you preview in a new window with glitch, but it doesn't work when it's previewed in the preview pane

Expected behavior

Youtube video's should playback whether muted or unmuted.

Screenshots and recordings

4fdb550d874f56d67fcba74be0c6a247.mp4

Vlite.js

6.0.3

Browser

Chrome 126.0.6478.62 (Officiële build) (64-bits)

OS

Windows 11

Additional context

No response

@carelevers carelevers added the bug Something isn't working label Jun 14, 2024
@yoriiis
Copy link
Member

yoriiis commented Jun 14, 2024

Hello @carelevers, thanks for your report!

I've tested the Youtube example with muted option and the video start correctly on poster click. If the video is in autoplay mode also. Can you share a reproductible example?

@carelevers
Copy link
Author

Hello @yoriiis, thanks for the quick response,

I updated the issue with a screen recording of this example: https://glitch.com/edit/#!/sage-quilted-hippopotamus, in a Chrome incognito window with all extensions disabled.

@yoriiis
Copy link
Member

yoriiis commented Jun 17, 2024

@carelevers I think the issue is on Glitch only. Do you reproduce the same issue outside of this site?

@carelevers
Copy link
Author

carelevers commented Jun 17, 2024

Hmm, yes, I am also experiencing the same issue on some sites where we use vlite with the YouTube provider. Additionally, in other sandbox environments, the issue persists: https://jsfiddle.net/a3tv6zpf/

fcc96a0bc81cf1a696f14adcff6113f5.mp4

I don't know if there are other ways to reproduce this behavior?

@carelevers
Copy link
Author

I also receive a warning when autoplay is set to true and muted is set to true. When I unmute the video, I get the following warning:
afbeelding

@yoriiis
Copy link
Member

yoriiis commented Jul 26, 2024

Sorry for the delay, I think the problem is visible when the player is inside an other iframe. Glitch and JSFiddle use iframe to sandbox the content.

The url of the Glitch iframe works: https://vlitejs-youtube-video.glitch.me
But if I create an iframe with this url, the problem is visible.

Are you using Vlitejs in an iframe? Normally the problem is only present in this case.

@yoriiis
Copy link
Member

yoriiis commented Jul 26, 2024

I also receive a warning when autoplay is set to true and muted is set to true. When I unmute the video, I get the following warning: afbeelding

This warning is normal because automatic playback with sound requires user interaction; it is the browser that decides whether sound will be activated, not Vlitejs.

More info from Chrome: https://developer.chrome.com/blog/autoplay

@carelevers
Copy link
Author

Hi, I managed to fix it! It wasn’t something with Vlitejs after all, sorry for the confusion :)

The issue was actually with this header in my .htaccess :
Header always set Permissions-Policy "accelerometer=self, autoplay=self, camera=(), gyroscope=self, magnetometer=(), microphone=(), payment=(), publickey-credentials-get=(), usb=()"

Specifically, the autoplay=self policy

Thanks for the help anyway!

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

No branches or pull requests

2 participants