问题
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