title: how to download and play youtube video on Android?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7203047/code-for-download-video-from-youtube-on-java-android">Code for download video from Youtube on Java, Android</a>  </p>
  </blockquote>
  
  
  
  <p>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?</p>
  
  <p>i tried following ways to play the video.</p>
  
  <p>1)<code>startActivity(new Intent(Intent.ActionView,Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM")));</code></p>
  
  <p>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.</p>
  
  <p>Then i tried</p>
  
  <p>2) <code>String Play = "iframe width=\"300\" height=\"400\" src=\"http://www.youtube.com/embed/cxLG2wtE7TM\" frameborder=\"0\" allowfullscreen&gt;&lt;/iframe&gt;";</code></p>
  
  <pre><code>myWebView.loadData(Play, "text/html", "utf-8");
  </code></pre>
  
  <p>if i try this,empty screen is coming. no video is playing.video might not be embedding into my Webview.</p>
  
  <p>3)finally i tried the sample code given in<br>
  <a href="http://keyeslabs.com/joomla/samplecode/introvideoactivity/IntroVideoActivity.java" rel="nofollow noreferrer">http://keyeslabs.com/joomla/samplecode/introvideoactivity/IntroVideoActivity.java</a></p>
  
  <p>if i use this,"Sorry This Video Cannot be played" alert is coming  :(</p>
  
  <p>please help me.thanks in advance.</p>