Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube Player API list with videos

I am using the YouTube Player API.

I want to make my own custom playlist directly in my code (not to use playlist ID from youtube)

Here is my playlist code which doesn't work

player.loadPlaylist({
    list:['mGalEx6ufUw', 'TaCUBtzKAnA', '4v8SPz4VfsU'], 
    listType: 'playlist', 
    index:0, 
    startSeconds:0, 
    suggestedQuality:'medium'
});

As the documentation says I can pass playlist ID or array with video IDs to parameter list, but it's not working.

If I write playlist ID instead of the array with video IDs it works.

like image 284
Ivan Dokov Avatar asked Feb 05 '12 09:02

Ivan Dokov


2 Answers

I solved this.

I think the API documentation seems to be wrong.
playlist ID and video IDs in loadPlaylist function should be used in a different way.

    function loadPlaylist_playlist_id() {
        player.loadPlaylist({
            'list': 'UUPW9TMt0le6orPKdDwLR93w',
            'listType': 'playlist',
            'index': 0,
            'startSeconds': 0,
            'suggestedQuality': 'small'
        });
    }
    function loadPlaylist_video_ids() {
        player.loadPlaylist({
            'playlist': ['9HPiBJBCOq8', 'Mp4D0oHEnjc', '8y1D8KGtHfQ', 'jEEF_50sBrI'],
            'listType': 'playlist',
            'index': 0,
            'startSeconds': 0,
            'suggestedQuality': 'small'
        });
    }

http://1004lucifer.blogspot.kr/2015/04/youtube-loadplaylist-function-issues-of.html

like image 196
1004lucifer Avatar answered Sep 29 '22 00:09

1004lucifer


I've found the answer for this problem with the help of Jeffrey Posnick in Google Groups.

You can make this working with the argument syntax instead of object syntax. More info here

like image 43
Ivan Dokov Avatar answered Sep 28 '22 23:09

Ivan Dokov