开发者

Embeding youtube videos with playlist parameter

开发者 https://www.devze.com 2023-02-22 18:16 出处:网络
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

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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消