youtube embed single video loop with playlist shows twice the same video

ε祈祈猫儿з 提交于 2019-12-25 03:37:19

问题


I am trying to embed a YouTube video with loop mode on, and to do so I have to set the playlist parameter otherwise it won't work:

documentation

The problem is when I do so i get a playlist with 2 videos on it, the same video appearing twice, which produces a very bad visual effect since i want one video to loop endlessly.

Any suggestions on how to do so? Thanks

Here's my code:

<iframe width="600" height="338" 
src="https://www.youtube.com/embed/VIDEO_ID/?playlist=VIDEO_ID&autoplay=1&loop=1&rel=0&showinfo=0&color=white" 
frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

回答1:


I don't think the following information is actually documented somewhere, but I want share the discovery I made by making some tests in the URL for trying solve your "problem".


Saying this, you can remove your "problem" - (which is: displaying the same video twice) - by modifying the URL as follows:

https://www.youtube.com/embed/VIDEO_ID_1/?playlist=VIDEO_ID_2&autoplay=1&loop=1&rel=0&showinfo=0&color=white

Explanation:

  • VIDEO_ID_1: Corresponds to the videoId intended to play continuously - (in loop).
  • VIDEO_ID_2: Corresponds to the videoId usted in the VIDEO_ID_1, BUT with the last letter changed. The idea is set a videoId that does not exist.

So, with the previous explanation, you can use the following video as an example:

Video: Stack Overflow is 10!

videoId: QwS1r1mc888

The modified URL shows the following:

https://www.youtube.com/embed/QwS1r1mc888?enablejsapi=1&loop=1&playlist=QwS1r1mc880&autoplay=1&rel=0&showinfo=0&color=white

N.B that the videoId QwS1r1mc880 does not exist (yet) - you could also replace this value for 15874598752 - which will never be a YouTube videoId (as far as I know).


Side note: I really hope this discovery won't be removed.



来源:https://stackoverflow.com/questions/53750408/youtube-embed-single-video-loop-with-playlist-shows-twice-the-same-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!