使用播放列表参数嵌入 YouTube 视频

发布于 2024-10-30 14:46:12 字数 753 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风追烟花雨 2024-11-06 14:46:12

嵌入式 AS2 播放器已被弃用,并且不会显示播放列表参数与它一起工作。

您需要使用嵌入式 AS3 播放器,只需将 version=3 添加到参数列表即可。

示例:

http://www.youtube.com/v/NKU6oOUho74?version=3&showsearch=0&version=3&enablejsapi=1&playerapiid=ytplayer&rel=0&fs=1&playlist=uDEQVgyNz88,AmKwF_Si734

其他提示:

  • 初始视频的 ID 不应该出现在播放列表中,除非您希望它播放两次。
  • 如果您不希望播放器在列表完成后停止,请添加loop=1。如果没有loop=1,即使用户也无法重新启动播放列表。

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:

http://www.youtube.com/v/NKU6oOUho74?version=3&showsearch=0&version=3&enablejsapi=1&playerapiid=ytplayer&rel=0&fs=1&playlist=uDEQVgyNz88,AmKwF_Si734

Other tips:

  • The ID of the initial video should not be in the playlist, unless you want it to play twice.
  • Add a loop=1 if you don't want the player to stop when the list is finished. Without loop=1, even the user can't restart the playlist.
掩耳倾听 2024-11-06 14:46:12

据我所知,您应该将 &playnext=1 添加到您的网址中。

As far as I know, you should add &playnext=1 to your URL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文