Android YouTube player - how do I get the list of videos in a channel and choose one to play?

一笑奈何 提交于 2019-12-11 07:45:36

问题


I am looking at the sample applications download for YouTube API from here: https://developers.google.com/youtube/android/player/downloads/

But there does not seem to be an example of how to display the videos of a channel and choose one to be displayed.

EDIT: I entered this url into my browser:

https://www.googleapis.com/youtube/v3/search?key=my_real_key&channelId=UCoLEarNS6E-Kbzoya_p7k2Q&part=snippet,id&order=date&maxResults=20

But I got this error:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured"
   }
  ],
  "code": 403,
  "message": "Access Not Configured"
 }
}

Thanks, Alex


回答1:


You need to look at the YouTube Data API. You will find there documentation about how the API can be accessed. You can also find client libraries.

You could also make the requests yourself. Here is an example URL that retrieves the latest videos from a channel :

https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20"

After that you will receive a JSON with video ids and details, and you can construct your video url like this :

http://www.youtube.com/watch?v={video_id_here}



回答2:


Your best bet is to read about and use YouTube Data API:

https://developers.google.com/youtube/2.0/developers_guide_java?hl=pl

It allows such behaviour.



来源:https://stackoverflow.com/questions/17680310/android-youtube-player-how-do-i-get-the-list-of-videos-in-a-channel-and-choose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!