Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube embed video auto loop without refresh

I'm currently using:

<iframe class="video" src="https://www.youtube.com/embed/VIDEO_ID?loop=1&amp;playlist=VIDEO_ID" frameborder="0" allowfullscreen></iframe>

in order to include a YouTube video in a web page and get it loop automatically.

The problem is that each time the video ends, it reloads in order to start again. This behaviour is annoying and also a waste of bandwidth.

Is there any way to make it auto-replay without refresh ? Something like setting the video to 00:00 when it reaches the end, instead of reloading it.

like image 295
Francesco Borzi Avatar asked Oct 18 '22 12:10

Francesco Borzi


1 Answers

I have the same issue, so I researched a solution to embed a YouTube video using an iFrame (recommended by YT) which is set to loop without that annoying refresh state.

Seems that loading the video programmatically via the iFrame Player API solves the issue we both are experiencing.

https://developers.google.com/youtube/iframe_api_reference

Also, there is a pretty nice open source jQuery solution which makes use of the iFrame Player API. you can find it here:

http://rochestb.github.io/jQuery.YoutubeBackground/

If you are using the jQuery.YoutubeBackground solution for embedding a video inside a instead of as a full screen background, set fitToBackground as false inside the YTPlayer object.

Hope this helps.

like image 191
jonask Avatar answered Oct 28 '22 22:10

jonask