Javascript 循环播放嵌入的 YouTube 视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10565448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Play an embedded youtube video in loop
提问by gigadot
Does anyone know how to make an embedded youtube video to play in loop?
有谁知道如何制作嵌入式 YouTube 视频以循环播放?
I have tried the code generated from official youtube developer websitebut it does not work at all. It doesn't replay after the video ends in both Firefox and Chrome. Here is the generated code that doesn't work.
我已经尝试了从官方 youtube 开发者网站生成的代码,但它根本不起作用。视频在 Firefox 和 Chrome 中结束后不会重播。这是生成的代码不起作用。
<object style="height: 390px; width: 640px">
<param name="movie" value="https://www.youtube.com/v/u1zgFlCw8Aw?version=3&feature=player_embedded&loop=1">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<embed src="https://www.youtube.com/v/u1zgFlCw8Aw?version=3&feature=player_embedded&loop=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344">
</object>
I have tried to google it but there aren't any good instruction.
我试过谷歌它,但没有任何好的说明。
回答by Chase
Try taking a look here https://developers.google.com/youtube/player_parameters#loop
尝试在这里查看https://developers.google.com/youtube/player_parameters#loop
Taken from the link
取自链接
Currently, the loop parameter only works in the AS3 player when used in conjunction with the playlist parameter.To loop a single video, set the loop parameter value to 1 and set the playlist parameter value to the same video ID already specified in the Player API URL:
目前,loop 参数仅在 AS3 播放器中与播放列表参数结合使用时才有效。要循环播放单个视频,请将循环参数值设置为 1,并将播放列表参数值设置为已在播放器 API URL 中指定的相同视频 ID:
http://www.youtube.com/v/VIDEO_ID?version=3&loop=1&playlist=VIDEO_ID
http://www.youtube.com/v/VIDEO_ID?version=3&loop=1&playlist=VIDEO_ID
It appears that you may be missing the playlist parameter needed in conjunction with the loop paramenter.
看来您可能缺少与循环参数一起使用的播放列表参数。
Demo link: http://jsfiddle.net/E3Euv/
演示链接:http: //jsfiddle.net/E3Euv/
回答by arttronics
I can not leave a comment for Chase's accepted answer, but to have the Playlist show only ONE video and not two, just use the comma which separates video id's and allows Playlist of 1to be realized.
我无法对 Chase 接受的答案发表评论,但要让播放列表仅显示一个视频而不是两个视频,只需使用逗号分隔视频 ID 并允许实现播放列表 1。
Example:
&playlist=,
示例:
&playlist=,
jsfiddle update:
http://jsfiddle.net/E3Euv/1/
jsfiddle 更新:http:
//jsfiddle.net/E3Euv/1/
回答by Chris Pink
I have exhausted the possibilities with Youtube. If nothing else it's a bandwidth sucker as the video is reloaded each time.
我已经用尽了 Youtube 的可能性。如果不出意外,它是带宽的傻瓜,因为每次都会重新加载视频。
I've uploaded my looping video to Vimeo. Problem solved.
我已将我的循环视频上传到 Vimeo。问题解决了。