Android YouTube app Play Video Intent

前端 未结 18 1418
太阳男子
太阳男子 2020-11-22 11:17

I have created a app where you can download YouTube videos for android. Now, I want it so that if you play a video in the YouTube native app you can download it too. To do t

18条回答
  •  暖寄归人
    2020-11-22 11:51

    You can use the Youtube Android player API to play the video if Youtube app is installed, otherwise just prompt the user to choose from the available web browsers.

    if(YouTubeIntents.canResolvePlayVideoIntent(mContext)){
                        mContext.startActivity(YouTubeIntents.createPlayVideoIntent(mContext, mVideoId));
    }else {
        Intent webIntent = new Intent(Intent.ACTION_VIEW, 
               Uri.parse("http://www.youtube.com/watch?v=" + mVideoId));
    
        mContext.startActivity(webIntent);
    }
    

提交回复
热议问题