媒体播放器使用YouTube?媒体播放器、YouTube

由网友(久违的故事)分享简介:我使用的开发一个示例应用程序的MediaPlayer 。通过使用原始资源文件夹,该视频可以played.B​​ut我想通过玩网址我。如何能做到这一点?我的code为:VideoView videoView =(VideoView)findViewById(R.id.VideoView);的MediaController...

我使用的开发一个示例应用程序的MediaPlayer 。通过使用原始资源文件夹,该视频可以played.B​​ut我想通过玩网址我。如何能做到这一点?

我的code为:

  VideoView videoView =(VideoView)findViewById(R.id.VideoView);
        的MediaController的MediaController =新的MediaController(本);
        mediaController.setAnchorView(videoView);
        //设置视频链接(MP4格式)
        乌里视频= Uri.parse(http://www.youtube.com/watch?v=T1Wgp3mLa_E);
        videoView.setMediaController(的MediaController);
        videoView.setVideoURI(视频)
        videoView.start();
 

解决方案

您需要得到正确的数据流(RTSP)的网址,而不是链接到您正在使用的播放器页面。您可以以编程方式使用谷歌数据API得到这个

一旦你这样做,你会简单地取代

  

http://www.youtube.com/watch?v=T1Wgp3mLa_E   同"rtsp://v8.cache1.c.youtube.com/CiILENy73wIaGQnxa4t5p6BVTxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"

使用VLC媒体播放器下载YouTube视频图解过程

在您现有的code,它应该工作。

注意:视频质量,分流到自己videoview的时候,可以比它的外观在YouTube网站或应用程序播放器播放时会非常差。

I am developing a sample application using MediaPlayer.By using the raw resources folder,the video can be played.But I want to play through URL.How can I achieve this?

My code is:

VideoView videoView = (VideoView) findViewById(R.id.VideoView);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoView);
        // Set video link (mp4 format )
        Uri video = Uri.parse("http://www.youtube.com/watch?v=T1Wgp3mLa_E");
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(video);
        videoView.start();

解决方案

You need to get the correct streaming(rtsp) url rather than the link to the player page you are using. You can get this programmatically using the google data api

Once you have done that you would simply replace

"http://www.youtube.com/watch?v=T1Wgp3mLa_E" with "rtsp://v8.cache1.c.youtube.com/CiILENy73wIaGQnxa4t5p6BVTxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"

in your existing code and it should work.

Note: The quality of video, when streaming to your own videoview, can be very poor compared to how it looks when played on the youtube site or player app.

阅读全文

相关推荐

最新文章