Android YouTube app Play Video Intent

前端 未结 18 1308
太阳男子
太阳男子 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:48

    Here's how I solved this issue:

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + video_id));
    startActivity(intent);
    

    Now that I've done some more research, it looks like I only needed 'vnd.youtube:VIDEO_ID' instead of two slashes after the colon (':' vs. '://'):

    http://it-ride.blogspot.com/2010/04/android-youtube-intent.html

    I tried most of the suggestions here and they didn't really work very well with all of the supposed "direct" methods raising exceptions. I would assume that, with my method, if the YouTube app is NOT installed, the OS has a default fallback position of something other than crashing the app. The app is theoretically only going on devices with the YouTube app on them anyway, so this should be a non-issue.

提交回复
热议问题