Android YouTube app Play Video Intent

前端 未结 18 1134
太阳男子
太阳男子 2020-11-22 11:17

I have created a app where you can download YouTube videos for android. Now, I want it so that if you play a video in the YouTube native app you can download it too. To do t

相关标签:
18条回答
  • 2020-11-22 11:34

    The Youtube (and Market application) are only supposed to be used with special ROMs, which Google released for the G1 and the G2. So you can't run them in an OpenSource-ROM, like the one used in the Emulator, unfortunately. Well, maybe you can, but not in an officially supported way.

    0 讨论(0)
  • 2020-11-22 11:34

    Found it:

    03-18 12:40:02.842: INFO/ActivityManager(68): Starting activity: Intent { action=android.intent.action.VIEW data=(URL TO A FLV FILE OF THE VIDEO) type=video/* comp={com.google.android.youtube/com.google.android.youtube.YouTubePlayer} (has extras) }
    
    0 讨论(0)
  • 2020-11-22 11:34

    Try this:

    public class abc extends Activity implements OnPreparedListener{
    
      /** Called when the activity is first created. */
    
      @Override
        public void onCreate(Bundle savedInstanceState)
      {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM")));          
    
    
        @Override
          public void onPrepared(MediaPlayer mp) {
            // TODO Auto-generated method stub
    
        }
      }
    }
    
    0 讨论(0)
  • 2020-11-22 11:35

    Replying to old question, just to inform you guys that package have changed, heres the update

    Intent videoClient = new Intent(Intent.ACTION_VIEW);
    videoClient.setData("VALID YOUTUBE LINK WITH HTTP");
    videoClient.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
    startActivity(videoClient);
    

    This works very well, but when you call normal Intent with ACTION_VIEW with valid youtube URL user gets the Activity selector anyways.

    0 讨论(0)
  • 2020-11-22 11:36

    Try this,

    WebView webview = new WebView(this); 
    
    String htmlString = 
        "<html> <body> <embed src=\"youtube link\"; type=application/x-shockwave-flash width="+widthOfDevice+" height="+heightOfDevice+"> </embed> </body> </html>";
    
    webview.loadData(htmlString ,"text/html", "UTF-8");
    
    0 讨论(0)
  • 2020-11-22 11:37

    This function work fine for me...just pass url string in function:

    void watch_video(String url)
    {
        Intent yt_play = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
        Intent chooser = Intent.createChooser(yt_play , "Open With");
    
        if (yt_play .resolveActivity(getPackageManager()) != null) {
                        startActivity(chooser);
                    }
    }
    
    0 讨论(0)
提交回复
热议问题