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

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

问题描述

我正在使用 MediaPlayer 开发一个示例应用程序.通过使用原始资源文件夹,可以播放视频.但我想通过 URL 播放.我该怎么做达到这个目标?

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?

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();

推荐答案

您需要获得正确的流媒体 (rtsp) 网址,而不是您正在使用的播放器页面的链接.您可以使用 google data api

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

完成后,您只需替换

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

在您现有的代码中,它应该可以工作.

in your existing code and it should work.

注意:与在 youtube 网站或播放器应用上播放时的外观相比,流式传输到您自己的视频视图时的视频质量可能非常差.

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天全站免登陆