Android YouTube app Play Video Intent

0 votes
I m working on a app where you can download YouTube videos for android. Now, I want if you play a video in the YouTube  app you can download it too. To do this, I need to know the Intent that the YouTube  app puts out in order to play the YouTube app.
my question is:
1. Can I download the YouTube app for my emulator, or...
2. What is the intent used when the user selects a video for playback.
Jun 2, 2022 in Others by polo
• 1,480 points
1,064 views

1 answer to this question.

0 votes

The best way to run videos on a different app is by first trying to resolve the package, so something like this:

public void playVideo(String key){

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

    // Check if the youtube app exists on the device
    if (intent.resolveActivity(getPackageManager()) == null) {
        // If the youtube app doesn't exist, then use the browser
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://www.youtube.com/watch?v=" + key));
    }

    startActivity(intent);
}
answered Jun 6, 2022 by nisha
• 2,210 points

Related Questions In Others

0 votes
0 answers

Can you delete android play store app and use the package name?

I have an app that's currently on ...READ MORE

Jun 7, 2022 in Others by polo
• 1,480 points
414 views
0 votes
2 answers

Code for download video from Youtube on Java, Android

Check the source code (HTML) of YouTube, ...READ MORE

answered Jun 9, 2022 in Others by nisha
• 2,210 points
4,343 views
0 votes
1 answer

How to open the Google Play Store directly from my Android application?

By using developer.andriod.com, one can solve this ...READ MORE

answered Feb 8, 2022 in Others by Rahul
• 9,670 points
524 views
0 votes
1 answer

How can I change IP in Android emulator

Here's the six step you need to ...READ MORE

answered Feb 24, 2022 in Cyber Security & Ethical Hacking by Edureka
• 12,690 points
7,858 views
0 votes
1 answer

Launching Google Maps Directions via an intent on Android

We can open Google Maps app using ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,016 views
0 votes
1 answer

How to make android phone flashlight blink?

This might be too fast to blink:- String[] ...READ MORE

answered Jun 6, 2022 in Others by nisha
• 2,210 points
1,453 views
0 votes
1 answer

How to open YouTube video link in android app?

The below code will do that: Intent intent ...READ MORE

answered Jun 1, 2022 in Others by nisha
• 2,210 points
1,799 views
0 votes
1 answer

I am not able to Autoplay youTube video in android chrome

It will play if you set it to ...READ MORE

answered Jun 6, 2022 in Others by nisha
• 2,210 points
1,344 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP