Reputation: 1224
I've embedded a Youtube player on my page, and I generate a playlist "on fly" using JavaScript. Can I add new videos at the end of the playlist during watching? Can I remove the videos from the beginning of the list?
Upvotes: 0
Views: 817
Reputation: 56034
You can, but you need to know the actual length of the playlist ahead of time when attempting to insert a video at the end of it. There's no "magic constant" that tells the YouTube API to put the video in the last position; you need to set the position of the new item to the correct index corresponding to the tail of the list.
To remove the first video, you would get the first playlist item (position 0) from the playlist and delete it.
You'd want to use the Google APIs client library for JavaScript and call methods on the youtube.playlistItems service.
Upvotes: 1