使用播放列表参数嵌入 YouTube 视频
我正在使用 javascript youtube api 嵌入 youtube 视频,但在使用 swfobject.embed 功能嵌入播放列表时遇到困难。我在 javascript api 文档中找到的代码是:
var splitSrc = src.split(",");
var params = { allowScriptAccess: "always", wmode: "transparent", allowFullScreen: "true" };
var atts = { id: "myytplayer" };
if (splitSrc.length > 1) {
swfobject.embedSWF("http://www.youtube.com/v/" + splitSrc[0] + "?showsearch=0&enablejsapi=1&playerapiid=ytplayer&rel=0&fs=1&playlist=" + src,
"PlayerYoutube", "0", "0", "8", null, null, params, atts);
}
其中 src 是逗号分隔的视频 ID 列表,但播放器仅加载 splitSrc[0] 中指定的第一个视频。
还有另一种方法可以做到这一点吗? 我这样做错了吗?
请有人帮我解决这个问题。
我有另一个工作方案,但它涉及大量的实现,我宁愿有一个简单的解决方案。
I am using the javascript youtube api to embed youtube videos, i am having difficulty in embedding playlists using the swfobject.embed functionality. The code im using which i found in the javascript api docs is:
var splitSrc = src.split(",");
var params = { allowScriptAccess: "always", wmode: "transparent", allowFullScreen: "true" };
var atts = { id: "myytplayer" };
if (splitSrc.length > 1) {
swfobject.embedSWF("http://www.youtube.com/v/" + splitSrc[0] + "?showsearch=0&enablejsapi=1&playerapiid=ytplayer&rel=0&fs=1&playlist=" + src,
"PlayerYoutube", "0", "0", "8", null, null, params, atts);
}
where src is a comma seperated list of video ids, but the player loads just the first video specified in splitSrc[0].
Is there another way of doing this?
Am i doing this wrong?
Please could someone help me with this issue.
I have another work arround but its going to be a lot of implementation involved, i would rather have a simple solution to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嵌入式 AS2 播放器已被弃用,并且不会显示播放列表参数与它一起工作。
您需要使用嵌入式 AS3 播放器,只需将
version=3
添加到参数列表即可。示例:
其他提示:
The embedded AS2 player has been deprecated and the playlist parameter doesn't appear to work with it.
You'll need to use the embedded AS3 player, which just requires you to add
version=3
to the parameter list.Example:
Other tips:
据我所知,您应该将 &playnext=1 添加到您的网址中。
As far as I know, you should add &playnext=1 to your URL.