媒体播放器使用YouTube? [英] Media player using YouTube?

查看:249
本文介绍了媒体播放器使用YouTube?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的开发一个示例应用程序的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"

在您现有的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.

这篇关于媒体播放器使用YouTube?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆