开发者

Embedding YouTube Playlist using SWFObject.embedSWF()

开发者 https://www.devze.com 2023-04-07 09:42 出处:网络
I\'m trying to use YouTube\'s JavaScript API to embed a playlist to my Facebook app. I tried using the standard code as shown by Google here to embed a simple video and it worked.

I'm trying to use YouTube's JavaScript API to embed a playlist to my Facebook app.

I tried using the standard code as shown by Google here to embed a simple video and it worked.

The code is:

    function loadPlayer() {
        // The video to load
        var videoID = "[My Video ID]";
        // Lets Flash from another domain call JavaScript
        var params = { allowScriptAccess: "always" };
        // The element id of the Flash embed
        var atts = { id: "ytPlayer" };
        // All of the magic handled by SWFObject (http://code.go开发者_C百科ogle.com/p/swfobject/)
        swfobject.embedSWF("http://www.youtube.com/v/" + videoID + 
                           "?fs=1&version=3&enablejsapi=1&playerapiid=player1", 
                           "videoDiv", "420", "315", "9", null, null, params, atts);
      }

But how do I use the YouTube API to embed a Playlist?

I'm aware of the playlist parameter on the embedSWF URL parameter, but what it does is append videos as to make a playlist on the fly.

I already have a playlist on my YouTube account, now I want to embed it using the API.

How can this be done?

Thanks!


I'm working on something similar and in looking for the solution to my problem may have found yours...

In the place where you have;

swfobject.embedSWF("http://www.youtube.com/v/" + videoID + 

Change that to:

swfobject.embedSWF("http://www.youtube.com/p/" + playlistID + 

I do believe that will work. That's what puts our playlist on the player. And yet, it is not the way we are hoping to display it. We would like a list below the player, so I am still searching for that answer.

I hope this helps you!


You dont need javascript or anything, you just go into your playlist, and next to the play all button it says share, click that then click embed and copy and past the code on your site.


This may help you to try on your own... http://jsfiddle.net/masiha/tFQEN/1/

0

精彩评论

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

关注公众号