I've had limited succes with the YouTube RTSP route.  I've written a
view that demonstrates one way to watch YouTube to a VideoView using
an mp4 stream.  I use this in my own products, and it works quite
well.  You can find information on that approach here:

http://keyeslabs.com/joomla/index.php/blogs/i-think-im-becoming-an-android/51-polish-your-app-free-embeddable-android-youtube-activity

Hope that helps.

Valentino XM wrote:
> Emulator wont play video from youtube. can someone tell me if this
> code is ok
>
>
> package info.shouraig.com;
>
> import java.io.IOException;
>
> import android.app.Activity;
> import android.media.MediaPlayer;
> import android.net.Uri;
> import android.os.Bundle;
> import android.util.Log;
> import android.widget.MediaController;
> import android.widget.VideoView;
>
> public class XSO7 extends Activity {
>       public final static String RTSP = "rtsp://v4.cache2.c.youtube.com/
> http://www.youtube.com/watch?v=8bmWwxixT0Y&feature=player_embedded";;
>       VideoView videoViewXS07;
>
>       /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         // ***VideoView to video element
>
>               VideoView videoView = (VideoView) 
> findViewById(R.id.videoViewXS07);
>               Log.v("videoViewXSO7", "***Video to Play:: " + RTSP);
>               MediaController mc = new MediaController(this);
>               mc.setAnchorView(videoView);
>               Uri video = Uri.parse(RTSP);
>               videoView.setMediaController(mc);
>               videoView.setVideoURI(video);
>               videoView.start();
>
>         MediaPlayer mp = new MediaPlayer();
>         try {
>                       mp.setDataSource(RTSP);
>               } catch (IllegalArgumentException e) {
>                       // TODO Auto-generated catch block
>                       e.printStackTrace();
>               } catch (IllegalStateException e) {
>                       // TODO Auto-generated catch block
>                       e.printStackTrace();
>               } catch (IOException e) {
>                       // TODO Auto-generated catch block
>                       e.printStackTrace();
>               }
>         try {
>                       mp.prepare();
>               } catch (IllegalStateException e) {
>                       // TODO Auto-generated catch block
>                       e.printStackTrace();
>               } catch (IOException e) {
>                       // TODO Auto-generated catch block
>                       e.printStackTrace();
>               }
>         mp.start();
>
>     }
> }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to