How to play Youtube video in ExoPlayer in Android?

后端 未结 4 1156
野的像风
野的像风 2020-12-07 16:35

I am trying to play youtube video in exoplayer but here is some confusion I don\'t know what is DASH url, I have only real youtube url like \"https://www.youtube.com/watch

4条回答
  •  不知归路
    2020-12-07 17:33

    to play youtube video in exoplayer we can use this library

    https://github.com/HaarigerHarald/android-youtubeExtractor
    

    and simply get the url like this and then play in exoplyer

    String youtubeLink = "http://youtube.com/watch?v=xxxx";
    
    new YouTubeExtractor(this) {
        @Override
        public void onExtractionComplete(SparseArray ytFiles, VideoMeta vMeta) {
            if (ytFiles != null) {
                int itag = 22;
            String downloadUrl = ytFiles.get(itag).getUrl();
            }
        }
    }.extract(youtubeLink, true, true);
    

提交回复
热议问题