I am trying to embed youtube video with autoplay, Loop, unmute. But Sound always mute when we use it with autoplay & loop.
<iframe src="https://www.youtube.com/embed/k6VjkfdKwFo?rel=0&modestbranding=1&autohide=1&mute=1&showinfo=0&controls=0&autoplay=1&loop=1&color=white&iv_load_policy=3&playlist=k6VjkfdKwFo" width="560" height="315" frameborder="0" allowfullscreen></iframe>
Related
I have a page that has a hundred or so youtube links in iframes, something like the sample code below. The page loads but the youtube images appear really slowly (several minutes) and some not at all, and I get thousands of warning messages. PHP is the code base.
For the sample code below with only 7 youtube links, the chrome browser yields 400+ console messages and it takes about 3 or 4 seconds to complete loading.
The chrome console messages I get are:
Category - other, qty. 406: Error with Permissions-Policy header: Unrecognized feature: 'ch-ua-full-version-list'.
Category - base.js, qty. 28: [Violation] Added non-passive event listener to a scroll-blocking event. Consider marking event handler as 'passive' to make the page more responsive. See
Category - base.js, qty. 14: [Violation] 'setTimeout' handler took (N)ms (N between 80-150ms)
Category - www-embed-player.js, qty.14: [Violation] 'setTimeout' handler took (N)ms (N between 80-150ms)
<body>
<div style="max-width:400px;margin:auto;">
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/T0olzS2ElKo" allowfullscreen="true" ></iframe></div><br>
</div>
</body>
Few questions I have, your suggestions are welcome:
What is happening that the browser is giving so many warning messages?
Is there a way to eliminate the console messages, get fast loading, with a little code tweaking?
If not (2), then what is a good coding approach? Perhaps to display the youtube image thumbnails first, then allow clicking on them to dynamically load the real video player in an iframe through an ajax routine? Is this the preferred method of displaying hundreds of youtube videos on a page?
Thanks in advance!
I think there are no problems in the code or even in the browser..
I have tried your code and the output shows like this:
It shows that the problem is from the video, you cant watch these videos. You can watch theme only at YouTube, because when I changed the videos URL it works fast and there are no problems..
It works like this:
You can try this code I changed the video URL and it works! You can change the URL :
<body>
<div style="max-width:400px;margin:auto;">
<div><iframe title="YouTube video player" src="https://www.youtube.com/embed/oGDGIICqB_s" allowfullscreen="true" ></iframe></div><br>
</div>
Mohammed Maged;
I've been trying to emulate this: https://codepen.io/chriscoyier/pen/zawHg
This works when the video is muted, however when I try and remove the &mute=1 in the URL, the video will no longer play.
original:
<iframe id="video" src="//www.youtube.com/embed/FKWwdQu6_ok?enablejsapi=1&html5=1&mute=1" frameborder="0" allowfullscreen></iframe>
adapted:
<iframe id="video" src="//www.youtube.com/embed/FKWwdQu6_ok?enablejsapi=1&html5=1" frameborder="0" allowfullscreen></iframe>
I'm not sure why this is happening.
The expected outcome I'm trying to achieve is on page load, the video starts automatically (with sound), but can be controlled with the custom play/ pause buttons thank you!
If I scroll down the video should stop.
I tried a few things from internet but didn't worked. I tried
how can I pause a youtube embed when a user scrolls away
How to play and pause a Youtube video in a webpage while scrolling(using javascript or jquery)?
Autoplay Youtube Video When Scrolled to
It would be a great help if someone can share a good resource of ANGULAR
THIS IS THE CODE FOR HTML I AM GETTING FROM DB
<div class="ast-oembed-container">
<iframe title="Genetics - 's preparation Program"
width="500" height="281" src="https://www.youtube.com/embed/J3CGg1NmA?feature=oembed"
frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media;
gyroscope; picture-in-picture" allowfullscreen>
I am creating a slider with images that when someone clicks one slide, opens a modal window with another slider with videos.
What I would like to achieve is: on click -> play the video. So if the third slide of the images is clicked, open and play the video automatically.
Here is a fiddle with the example, but the play is not working...
<iframe id="vimeo-player" src="https://player.vimeo.com/video/218392001?color=637df2?api=1&autoplay=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
You have to add &autoplay=1&loop=1 after ?api=1 to iframe
it is possible to create a button to play and pause the youtube video when using the youtube script, i mean this
<iframe title="YouTube video player" width="853" height="510" src="http://www.youtube.com/embed/LVcXdMB1_YA?rel=0&hd=1" frameborder="0" allowfullscreen></iframe>
i'm using this to load the video, but i would like to have for example a link, saying "Play Video", and when the user click the link, the video start to play, all i've tried ends up in nothing, i even think that it is no way to do this, but to be sure, i came here to SO.