Reputation: 35
I am new to Youtube Api for Android . I want to play the video which is been streaming live on youtube on my channel by using Wirecast software. I have downloaded all the API Code . And my app is successfully running.
in API code, there is one method player.cueVideo("n6KBk1kR124"); // Plays https://www.youtube.com/watch?v=n6KBk1kR124
this plays the video according the videoID we are specifying in above method. It plays successfully. But the thing is, whenever we put new stream live video on youtube, the videoID changes every time we start new streaming video. due to this i have to change the VideoID and build the app every time I change the VideoID.
So is there any way to dynamically set the specific URL or videoID for streaming any new video we put live . Please guys ,need your help. your help will be greatly appreciated. Thanks :)
Upvotes: 1
Views: 1081
Reputation: 560
go to google api console and get a developer key. then add that key to your project and activate the youtube api on the google api console. Then on youtube create a play list and set all videos you won't on your app inside that play list. make an URL request to youtube using the "LibraryID":"XXXXXXXXX", and on the request you will receive the ID of all videos that are inside that play list. then you have to go trough the revived response and show the video you want. You can show the firs, second, last video, all videos.
this is the url to get the response:
String url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=YOUR_PLAY_LIST_ID&key=YOUR_API_KEY";
Upvotes: 1
Reputation: 12382
Make server API that return json
or xml
response to get latest VideoID like below.
//For ex. json respose
{
"VideoID":"n6KBk1kR124"
}
When open user app, make HTTP
request to server and parse response to get new/latest VideoID
.
Use that latest VidoeID
for streaming any new video.
Upvotes: 2