how to loop two videos using youtube iframe code

后端 未结 2 1014
深忆病人
深忆病人 2021-01-28 18:39

I use the following code in my web page to successfully autoplay and loop one video. Now, I\'d like to add another video, essentially looping two videos. So, after one video is

相关标签:
2条回答
  • 2021-01-28 19:14

    For add more than one video in your iframe, you can use the following code:

    https://www.youtube.com/embed/<VIDEO_ID_1>?rel=0&version=3&playlist=<VIDEO_ID_2>,<VIDEO_ID_3>,<VIDEO_ID_N>&loop=1&autoplay=1
    

    Where:

    • VIDEO_ID_1: is the first videoId to reproduce.
    • VIDEO_ID_2, VIDEO_ID_3, VIDEO_ID_N and so on will be the videoIds you want include.

    In this way, you can include a max of 196 or 200 videos in the same iframe1 that will autoplay and loop once the final videoId is reached.

    This is a small sample with 4 videos on it.

    This is another sample with 93 videos on it.

    If you check this playlist, you'll see that it has more than 1000 videos on it - (1653 videos to be exact), but, the iframe resets the threshold to 196 or 200 videos approximately.


    1 I discover this threshold when I tried to answer this question in Stack Overflow and you can check it by yourself if you enter to the Youtube website - this playlist and check that it will show only the first 200 videos on it.

    This might be a threshold set (and undocumented) by YouTube.

    0 讨论(0)
  • 2021-01-28 19:20

    A similar question was asked before about iframe and looping. I found this from another question on stackoverflow, a youtube link has a special ? parameter: autoplay. For example in this link

    src="https://www.youtube.com/embed/M7lc1UVf-VE ?&autoplay=1& loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3&playlist=M7lc1UVf-VE"

    Try adding ?&autoplay=1& considering that worked for someone else.


    I found it from here

    Update

    If you wanna play multiple videos you can do it simply and embed a playlist. You can find how to do so in this article at the Embed a playlist section. Hope this helps.

    0 讨论(0)
提交回复
热议问题