Reputation: 203
I'm trying to get a element to autoplay, with sound on, when the HTML loads. I set the autoplay attribute. The videos in question are Youtube embeds and the iframe also has autoplay enabled. I also set up autoplay in the Permissions-Policy headers. For some reason it works on desktop but not mobile. I don't want the audio muted as this is a music video.
The website is a collection of music videos and the user has a button they can click to enable/disable autoplay. When enabled, when the current video ends they are redirected to a page with the next video. So it's not intrusive, it's what they want. But I can't find a way for mobile videos to actually autoplay it with sound. According to this Google article, it should work via iframe delegation. There's gotta be away to do this as YouTube does this.
Any help is appreciated!
Upvotes: 0
Views: 56
Reputation: 15906
"When the current video ends they are redirected to a page with the next video"
To get autoplay with sound, do not re-direct to another page.
Solution:
On your site, create an i-frame that will contain and load these other "redirected to" pages.
I assume the Youtube API is involved in order to know when a video has ended? If yes, then the page with the Youtube embed must emit a (custom) event so your main page listens for it and knows to change the .src
of the main container.
Upvotes: 0