Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:00:37+00:00 2026-06-08T00:00:37+00:00

In my Android app I’d like the user to tap an image once, have

  • 0

In my Android app I’d like the user to tap an image once, have a youtube video play automatically and when the video is done the user is immediately returned to the app. What’s the best way to do this in Android?

I tried using intents. This works in that the video comes up on what I think is a youtube web page. However playing the video requires another tap. I’d like to avoid this if possible.

I tried the whole MediaPlayer, prepareAsync, setOnPreparedListener and never got it to work. For some reason onPrepared was never called. No exceptions were thrown. I’m using the emulator to test and I’m new to Android so I’m not sure if the behavior will be different on physical devices.

I got this working well on iOS by getting creative with webviews. I’m hoping it’s more straightforward on Android. The docs sure make it sound straight forward.

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:00:40+00:00Added an answer on June 8, 2026 at 12:00 am

    Update: Everything below is still correct, but the official YouTube API for Android is now available.

    By far, the easiest way to play a YouTube video on Android is to simply fire an Intent to launch the native Android YouTube app. Of course, this will fail if you are not on a certified Google device, that doesn’t have the complement of Google apps. (The Kindle Fire is probably the biggest example of such a device). The problem with this approach is that the user will not automatically wind up back at your app when the video finishes; they have to press the Back button, and at this point you’ve probably lost them.

    As a second option, you can use the MediaPlayer API to play YouTube videos. But there are three caveats with this approach:

    1) You need to make a call to YouTube’s GData webservice API, passing it the ID of the video. You’ll get back a ton of metadata, along with it the RTSP URL that you should pass to MediaPlayer to play back an H.264-encoded stream. This is probably the reason why your attempt to use MediaPlayer failed; you probably weren’t using the correct URL to stream.

    2) The GData/MediaPlayer approach will only play back low-resolution content (176×144 or similar). This is a deliberate decision on the part of YouTube, to prevent theft of content. Of course, this doesn’t provide a very satisfactory experience. There are back-door hacks to get higher resolution streams, but they aren’t supported on all releases of Android and using them is a violation of YouTube’s terms of service.

    3) The RTSP streams can be blocked by some internal networks/firewalls, so this approach may not work for all users.

    The third option is to embed a WebView in your application. There two approaches you can take here:

    1) You can embed a Flash object and run the standard desktop Flash player for YouTube. You can even use the Javascript API to control the player, and relay events back to the native Android app. This approach works well, but unfortunately Flash is being deprecated on the Android platform, and will not work for Android 4.1 and later.

    2) You can embed a <video> tag to play YouTube via HTML5. Support for this varies between various releases of Android. It works well on Android 4.0 and later; earlier releases have somewhat spotty HTML5 <video> support. So, depending upon what releases of Android your application must support, you can take a hybrid approach of embedding HTML5 on Android 4.x or later, and Flash for all earlier versions of Android.

    There are several threads here on StackOverflow about using HTML5 to play YouTube video; none of them really describe the entire process you must follow in one place. Here’s links to a few of them:

    Android – How to play Youtube video in WebView?

    How to embed a YouTube clip in a WebView on Android

    Play Youtube HTML5 embedded Video in Android WebView

    All of this will get dramatically easier in the weeks/months to come; at Google I/O 2012, they presented/demoed a new YouTube API for Android that will support direct embedding of YouTube content in your application, with full support back to Android 2.2 (about 95% of the Android userbase as of this writing). It can’t arrive fast enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android app that looks absolutely horrible if the user sets their
My Android app consists of a simple tablayout (3 tabs). Let's say the user
My android app works on landscape mode. I have a listview that contains some
I have written an Android app (target 3.2) using Eclipse 3.7, I tried to
My Android app is trying to urge a user to upgrade a particular app
My Android app has a layout that looks like this: --------------------- | | |
My Android app sends/retrieves data to/from the user's own PC using HTTP and it's
My Android app connects to a asp.net web service to register the user. When
My Android app is retreiving the user's friends list and displaying it to them
My Android app has an Update class and I have, in the same app,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.