3

Possible Duplicate:
Code for download video from Youtube on Java, Android

i want to play a youtube video on a button click.but i dont want that video to be played using youtube site.i want to play it locally.how to do that?

i tried following ways to play the video.

1)startActivity(new Intent(Intent.ActionView,Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM")));

if i use this way,youtube site is opening.after playing that video,it is showing some other videos as suggitions.i dont want to show that related videos as suggitions.i want to play only the video that i mentioned in intent.

Then i tried

2) String Play = "iframe width=\"300\" height=\"400\" src=\"http://www.youtube.com/embed/cxLG2wtE7TM\" frameborder=\"0\" allowfullscreen></iframe>";

myWebView.loadData(Play, "text/html", "utf-8");

if i try this,empty screen is coming. no video is playing.video might not be embedding into my Webview.

3)finally i tried the sample code given in
http://keyeslabs.com/joomla/samplecode/introvideoactivity/IntroVideoActivity.java

if i use this,"Sorry This Video Cannot be played" alert is coming :(

please help me.thanks in advance.

Community
  • 1
  • 1

1 Answers1

0

You could try an easy hack in #1: use the embedded URL and see what happens: http://www.youtube.com/embed/VIDEO_ID

Mister Smith
  • 27,417
  • 21
  • 110
  • 193
  • hi smith,i tried your solution.its working great.but i am unable to come back to my application after pressing back button. back button press causes the video to play again.how to return back to my application? – srikanth sanagapalli Oct 31 '11 at 05:47
  • and one more thing.for some videos,it is giving alert "Sorry,This Video Cannot be Played" .please help me – srikanth sanagapalli Oct 31 '11 at 07:32
  • Hum, once you are in the browser application, the key presses are managed by it, so I don't think you have any control over that. Maybe you should try an hybrid application using WebView, or start an intent to the android native youtube application. – Mister Smith Oct 31 '11 at 08:27