Reputation: 45942
I am using the following code to start an intent to run a youtube video:
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("vnd.youtube:" + YOUTUBE_VID_ID)
);
startActivity(intent);
My only problem is that some videos give me the error (on some devices) "Not available in your country" although if I use the browser, the videos are displayed normally.
All the videos are not listed but I am still able to view some of them. I can not find the link. I might have access to the youtube channel if I know where to fix this.
Upvotes: 0
Views: 1082
Reputation: 1359
Don't force your users to use the youtube application. Doing so limits them and the fundamental design around sharing and cross app communication of android. In the end they will not like the usability of your app.
Instead launch an intent to let them choose what video application to use:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(MY_YOUTUBE_URL)));
That way if they have an app that will do things like stream it to their TV then they can use that instead of the youtube player.
edit by Sherif
Just use:
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=" + YOUTUBE_VID_ID));
startActivity(intent);
Upvotes: 2