2

I have a VideoView and I set URI of youtube video and set android.permission.INTERNET but I got this message when I want to play the video .. "you can't play the video"

this code piece for video player

 mVideoView = (VideoView) findViewById(R.id.skillVideo);
            mVideoView.setVideoURI(Uri.parse("http://www.youtube.com/watch?v=1_pryg5HFYY"));
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();

and this is the VideoView in xml layout file :

....

<VideoView  android:id="@+id/skillVideo" 
            android:layout_width="wrap_content"
            android:layout_height="200dp"></VideoView>



....
Adham
  • 63,550
  • 98
  • 229
  • 344
  • have you checked these http://stackoverflow.com/questions/4654878/how-to-play-youtube-video-in-my-android-application http://stackoverflow.com/questions/1007695/streaming-youtube-videos – Lavanya Jul 02 '11 at 11:55
  • what is the wrong in what I have posted ? Can I play it in the emulator ? – Adham Jul 02 '11 at 11:58
  • yes i guess but still if u hav problem check the ones which i gave and also try googling – Lavanya Jul 02 '11 at 12:01

2 Answers2

1

In this code here is what I have done, I removed the MediaControllers from the UI and ran my youtube video stream threw rtsp and in my layout there is a basic VideoView with my needed button. you can see this in real action here on the Android.

Markethttps://market.android.com/details?id=com.sbrecords&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5zYnJlY29yZHMiXQ.. video_url = "rtsp://v7.cache3.c.youtube.com/CjgLENy73wIaLwkeUryQ8ZkCqRMYJCAkFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNg6KnB9MbH8sVODA==/0/0/0/video.3gp";

    try {
            final VideoView videoView =(VideoView)findViewById(R.id.videoView1);
      //1   //mediaController = new MediaController(Splashscreen.this);
      //2   //mediaController.setAnchorView(videoView);
            // Set video link (mp4 format )
            Uri video = Uri.parse(video_url);
            //videoView.setMediaController(mediaController);
            videoView.setVideoURI(video);
            videoView.setOnPreparedListener(new OnPreparedListener() {
                public void onPrepared(MediaPlayer mp) {
                    progressDialog.dismiss();
                   videoView.start();
                }
            });

         }catch(Exception e){
              progressDialog.dismiss();
             System.out.println("Video Play Error :"+e.getMessage());
         }
// Thread to waste time while displaying splash screen
Thread SplashThread = new Thread() {
    @Override
    public void run() {
        try {
            synchronized (this) {
                // Wait given period of time
                wait(7450000);
            }
        } catch (InterruptedException ex) {
        }

        finish();
Hardik Joshi
  • 9,477
  • 12
  • 61
  • 113
KaSiris
  • 407
  • 3
  • 13
  • it is 3gp ... here is a video link showing how to get the rtsp link http://www.youtube.com/watch?v=ZA7Kkhv30WA – KaSiris Apr 10 '12 at 04:01
-1

@Adham have you thought about using the YouTube API for Android. They have a great playerview which gives you lots of control and event-listening ability on the video. I recently posted a tutorial on using the API if it might fit your needs, check it out here

MikeIsrael
  • 2,871
  • 2
  • 22
  • 34