Louis93
Louis93

Reputation: 3913

How do I navigate through a playlist using the Youtube Javascript API?

Once I've created a playlist using the loadPlaylist method which is just an array of video urls, I want to be able to navigate to through the playlist.

The function described in the documention playVideoAt(int) seems to be able to do this, but after calling it a single time, you lose reference to the entire playlist.

Meaning that I could call playVideoAt(2) and navigate to the third video in the playlist I've created, but I cannot use this function again, and I am now unable to navigate any further through the list.

Are there any workarounds or suggested fixes I could use?

Upvotes: 0

Views: 582

Answers (1)

jlmcdonald
jlmcdonald

Reputation: 13667

Here's an issue that was recently filed for this problem -- it does seem to be a recently introduced bug.

https://code.google.com/p/gdata-issues/issues/detail?id=5018&q=playvideoat&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary

If you're in need of a temporary workaround, in lieu of videoPlayAt() you could just call 'cuePlaylist() again (or loadPlaylist() to have it autoplay) and pass it an index, like this:

player.cuePlaylist({'listType':'playlist','list':'[PLAYLIST ID]','index':[VIDEO INDEX NUMBER]});

You can test it in this fiddle:

http://jsfiddle.net/jlmcdonald/uz68V/3/

Hopefully it'll be resolved soon.

Upvotes: 1

Related Questions