3

I'm playing YouTube from URL, but when I play the video it shows the following error:

unable to open video

I'm using this code:

video =new VideoView(this);
video.setVideoURI(path);

System.out.println("my path"+path);

ctlr = new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();`

The path is correct. I checked on the Web also. Why am I getting an error like that?

The links are like: http://www.youtube.com/v/8B-Vu94Sd4M?f=videos&app=youtube_gdata

Bill the Lizard
  • 386,424
  • 207
  • 554
  • 861
Udaykiran
  • 5,863
  • 9
  • 42
  • 75

1 Answers1

2

You can't simply give the VideoView a Youtube URL and expect it to play the video. This seams to be impossible at all (see here).

However, you might want to use a YouTube Intent and let the System handle it: Link

Community
  • 1
  • 1
Lukas Knuth
  • 25,069
  • 15
  • 82
  • 110
  • I wanna customize my screen so that it plays youtube video file and some widgets around. Is this possible? – Udaykiran Jun 28 '11 at 14:47
  • As I see it from the linked threads above, it doesn't seam so. If it is, the [YouTube API Documentation](http://code.google.com/apis/youtube/overview.html) might be the right place to look for it. – Lukas Knuth Jun 28 '11 at 14:56