On Wed, Dec 23, 2009 at 11:49 AM, Valentino XM <shourai...@gmail.com> wrote:
> INcase anyone out there isĀ“attempting to stream youtube via an Android
> Emulator. my best advice at this point is not to waste your time. It
> simply does not work, right now..

The qualifier here is "via an Android Emulator", streaming YouTube
works fine on the real devices. The emulator does not support the UDP
networking required for the RTSP:// streams that YouTube offers.

There are other options (should you need to support the emulator). You
could use the video ID to extract a playback token, and use YouTube's
/get_video request to pull the 3GP file format from YouTube's server
and play that. An example of this approach (including Java code) can
be found here: 
http://keyeslabs.com/joomla/index.php/blogs/i-think-im-becoming-an-android/51-polish-your-app-free-embeddable-android-youtube-activity.
There are other benefits to this, such as not requiring a good quality
network connection to play the video.

For example, this works for me:

public class TestActivitySnapshot extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        streamYoutubeVideo();
    }

    private void streamYoutubeVideo() {
        VideoView video = (VideoView)findViewById(R.id.video_view);

        // "token" value retrieved from
http://www.youtube.com/get_video_info?&video_id=ghIoTW10qwc

        video.setVideoURI(Uri.parse("http://www.youtube.com/get_video?"; +
                                "video_id=ghIoTW10qwc" + /* YouTube video ID */
                                
"&t=vjVQa1PpcFMQUzL0L4TXtChsSDb2hogA4XEbSjFRf9U%3D" + /* "token" value */
                                "&fmt=17")); /* 17 = low quality, 18 = high 
quality */
                
        video.start();
    }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to