How does this YouTube latest video code work? -


I have used some code to find the latest video from a specific channel, I can see how it Works, but I'm not sure how this is the source of the video if someone can explain that would be great

   & Lt; Div id = "static_video" & gt; & Lt; / Div & gt; & Lt ;! - Source Latest Video - & gt; & Lt; Script type = "text / javascript" & gt; Function show video (feedback) {if (feedback data & response.data.items) {var item = response.data.items; If (items length = gt; {var items = objects [0]; Var videid = "http://www.youtube.com/embed/"+item.id; Console.log ("Latest ID: '" + + VideoID + "' '); Var video =" & lt; Iframe width = '720' height = '480' src = '"+ VideoID +' frameborder = '0' permission screen & gt; & lt; / iframe & gt;"; . $ ('# Static_video') HTML (video); }} & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "https://gdata.youtube.com/feeds/api/users/UC9DiuD3z0btMOAMG_FvDRag/uploads?max-results=1&orderby=published&v=2&alt=jsonc& callback = ShowVideo "& gt; & Lt; / Script & gt;   

This can be seen

There will be another help, how can I show all the videos with the search box, search well through them. Sorry if I feel greedy but this will be a great help, if someone can understand.

Edit: Bump, I do not like the bump, but I need it, please help me!

The first API V2 is deprecated, you need to use it with the resource < P> You have to follow it to get an API key, one.

Use this parameter to get the latest upload of the channel:

  section: 'snippet' or 'id' channel id: 'UC9DiuD3z0btMOAMG_FvDRag' maxResults: 1 command : Date   

{YOUR_API_KEY}

Output:

  "item": [{type: "YouTube # search result" , "Idag": "\" PSNN-HSKIX6 ORVNHGGLLLLVK / 9R2L5FJB6 -YSIDD37YY5KG8I \ "", "ID": {"Type": "YouTube # Video "," video id ":" WH8U2NQ_fnA "}}   

Then you have the final video ID of the channel, after which, you need to use it. A live example to show you how the player works:

You must copy the code with the video ID from the previous step!

Example:

your index.html

 Add this line to the end of the body in  & lt; script src = "https://apis.google.com/js/client.js?onload=googleApiClientReady">  gt; ;   

and javascript example is:

  function googleApiClientReady () {var apiKey = 'YOUR_API_KEY', youtubeId, request; Gapi.client.setApiKey (apiKey); Gapi.client.load ('youtube', 'v3', function () {request = gapi.client.youtube.search.list ({part: 'id', channel id: 'UC9DiuD3z0btMOAMG_FvDRag', maximum result: 1, order : Date}); Request.execute {if (response.pageInfo.totalResults! = 0) {youtubeId = response.result.items [0] .id.videoId;}})}}}}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -