title: Android youtube video playing with rstp and vnd.youtube://
body: <p>//this method just shows up youtube loading</p>
  
  <ol>
  <li><code>Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + videoId))    startActivity(intent);</code>  </li>
  </ol>
  
  <p>//second method is not playing video at all
  2 .</p>
  
  <pre><code>public class MyTask extends AsyncTask&lt;Void, Void, Void&gt;
      {
  
      @Override
      protected void onPreExecute() {
          // TODO Auto-generated method stub
          super.onPreExecute();
          mProgressBar.setVisibility(LinearLayout.VISIBLE);
  
      }
  
      @Override
      protected Void doInBackground(Void... params) {
          // TODO Auto-generated method stub
          url=getUrlVideoRTSP(urlRstp[0]);
          rstlUrl=Uri.parse(url);
  
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          // TODO Auto-generated method stub
          super.onPostExecute(result);
          //Toast.makeText(VODVideoPlayActivity.this, url, Toast.LENGTH_LONG).show();
          //System.out.println(url);
  
          mVideoView.setVideoURI(rstlUrl);
          //MediaController mc = new MediaController(VODVideoPlayActivity.this);
          //mVideoView.setMediaController(mc);
          //mVideoView.requestFocus();
          mVideoView.start();          
          //mc.show();
          mProgressBar.setVisibility(LinearLayout.GONE);          
      }
  
  
  
  
  }
  
  public static String getUrlVideoRTSP(String urlYoutube)
  {
      try
      {
          String gdy = "http://gdata.youtube.com/feeds/api/videos/";
          DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
          String id = extractYoutubeId(urlYoutube);
          URL url = new URL(gdy + id);
          HttpURLConnection connection = (HttpURLConnection) url.openConnection();
          Document doc = documentBuilder.parse(connection.getInputStream());
          Element el = doc.getDocumentElement();
          NodeList list = el.getElementsByTagName("media:content");///media:content
          String cursor = urlYoutube;
          for (int i = 0; i &lt; list.getLength(); i++)
          {
              Node node = list.item(i);
              if (node != null)
              {
                  NamedNodeMap nodeMap = node.getAttributes();
                  HashMap&lt;String, String&gt; maps = new HashMap&lt;String, String&gt;();
                  for (int j = 0; j &lt; nodeMap.getLength(); j++)
                  {
                      Attr att = (Attr) nodeMap.item(j);
                      maps.put(att.getName(), att.getValue());
                  }
                  if (maps.containsKey("yt:format"))
                  {
                      String f = maps.get("yt:format");
                      if (maps.containsKey("url"))
                      {
                          cursor = maps.get("url");
                      }
                      if (f.equals("1"))
                          return cursor;
                  }
              }
          }
          return cursor;
      }
      catch (Exception ex)
      {
          Log.e("Get Url Video RTSP Exception======&gt;&gt;", ex.toString());
      }
      return urlYoutube;
  
  }
  
  protected static String extractYoutubeId(String url) throws MalformedURLException
  </code></pre>