I am making an app that can stream a live YouTube video to my app. I want to use ExoPlayer. I went through the demo app of ExoPlayer, and the URL they use in DASH streaming is something like this :
"uri":"http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0"
This is working.
I don't know how to get such a URL and I end up here. Does that mean that I can't stream from YouTube even if the video is my own? (especially Live videos) If I can how can I get such a URL for my video?
I have learned that DASH URLs are actually something that are internal to Google and you might need to use decoder to be able to get your URL.
For this, you may want to try the following solution given by Karim Abdell Salam in this SO post:
- First you need to call this url:
http://www.youtube.com/get_video_info?&video_id=v1uyQZNg2vE
and don't forget to change the last id with the target one.- Now you will get notice to download a file called
get_video_info
with no extesion.- Try to open this file using notepad and so.
- Now you have the right data but you can't read it because its encoded You need HTML decoder to read this data. Use this one:
http://meyerweb.com/eric/tools/dencoder/
. Just paste your data and press decode a several times to ensure it decoded well- Finally, search for a key called
dashmpd
and enjoy your URL
You may want to also check these links for more helpful information and updates:
- YouTube video regarding ExoPlayer: Adaptive video streaming on Android
- AndroidDev blog - Using ExoPlayer to play Youtube videos, don't know where the example URL's in the demo app are coming from.
- ExoPlayer Release Notes
Lastly, you may opt to also try playing live videos on android version 4.2.2 without necessarily using an ExoPlayer as mentioned in this SO post.
来源:https://stackoverflow.com/questions/40761192/streaming-a-youtube-live-video-dash-to-android-app-with-exoplayer