So I want to put a tab into my app that shows a feed of the latest videos from a YouTube channel. The tab is already there, just need to discover how to put the videos. How would I accomplish that?
-
possible duplicate of [How to play YouTube video in my Android application?](http://stackoverflow.com/questions/4654878/how-to-play-youtube-video-in-my-android-application) – sunny Aug 15 '15 at 22:06
1 Answers
You require the ID of the uploads playlist from the user
https://developers.google.com/youtube/v3/docs/channels/list#try-it
Do a http GET request like this
GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=jambrose42&key={YOUR_API_KEY}
You can specify the username with the forUsername={username} param, or specify mine=true to get your own (you need to authenticate first). Include part=contentDetails to see the playlists.
In the result. Grab that "upload" playlist ID.
Next, get a list of videos in that playlist:
GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=50&playlistId=UUpRmvjdu3ixew5ahydZ67uA&key={YOUR_API_KEY}
For Reference -
https://developers.google.com/youtube/v3/docs/playlistItems/list#try-it

- 423
- 1
- 5
- 16
-
Thanks. Now that I have that list of videos? How would I put them into Android Studio? – Nicholas Godoy Aug 16 '15 at 01:17
-
You parse the relevant information you want and then inject them in to your views, lets say - you have a recyclerview/listview and each item has the view name and the imageview for the thumbnail - you just iterate through the api response and keep injecting the relevant information in each listview item – borax12 Aug 16 '15 at 05:34