youtube嵌入带有播放列表的单个视频循环,显示同一视频的两倍 [英] youtube embed single video loop with playlist shows twice the same video
问题描述
我正在尝试在循环模式下嵌入YouTube视频,为此,我必须设置播放列表参数,否则它将不起作用:
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:
< a href = https://developers.google.com/youtube/player_parameters?#loop rel = nofollow noreferrer>文档
问题当我这样做时,我得到一个播放列表,上面有2个视频,同一视频出现两次,这会产生非常差的视觉效果,因为我希望一个视频无休止地循环播放。
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
这是我的代码:
<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>
推荐答案
我认为以下信息并未实际记录某处,但我想分享我通过在URL中进行一些测试来尝试解决您的问题而获得的发现。
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
说明:
-
VIDEO_ID_1
:与videoId $对应c $ c>打算连续播放-(循环播放)。
-
VIDEO_ID_2
:与VIDEO_ID_1
中使用的videoId
相对应,但最后一个信变了。这个想法是设置一个不存在的videoId
。
VIDEO_ID_1
: Corresponds to thevideoId
intended to play continuously - (in loop).VIDEO_ID_2
: Corresponds to thevideoId
usted in theVIDEO_ID_1
, BUT with the last letter changed. The idea is set avideoId
that does not exist.
因此,根据前面的解释,您可以使用以下视频作为示例:
So, with the previous explanation, you can use the following video as an example:
视频:堆栈溢出为10!
videoId: QwS1r1mc888
修改后的URL显示以下内容:
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
注意,videoId
QwS1r1mc880
不存在(还)-您也可以将此值替换为15874598752
- (据我所知)永远不会是YouTubevideoId
。
N.B that the videoId
QwS1r1mc880
does not exist (yet) - you could also replace this value for15874598752
- which will never be a YouTubevideoId
(as far as I know).
侧面注:我真的希望此发现不会被删除。
Side note: I really hope this discovery won't be removed.
这篇关于youtube嵌入带有播放列表的单个视频循环,显示同一视频的两倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!