I want to retrieve an array of video ID's using a youtube playlist ID.
Basicually a function getPlaylist(playlist)
that returns
[{'title':'Video1 Title', 'ID':'Video1 ID'},
{'title':'Video2 Title', 'ID':'Video2 ID'},
{'title':'Video3 Title', 'ID':'Video3 ID'}];
I currently have this, but making it return data in an array would require a major rewrite, and I'm not sure how to approach it.
I want to be able to do var stuff = getPlaylist(ID);
, and reference the entered ID like stuff[4].title
and so, and easily handle the response in for loops etc.
I want to do this with as few lines of code as possible, and without libraries and API's (like jQuery and the youtube javascript API).
Create a variable outside of the loop
var arrayOfvideoIDs = [];
inside your loop
for (....) {
...
list_data += '<li>'+videoID+'</li>';
arrayOfvideoIDs.push(videoID);
}
You now have an array of videoID
s
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments