is there a way to play streaming youtube video from my activity?

一世执手 提交于 2019-11-29 18:14:10

Google are releasing android components for YouTube "in the coming months", so hopefully by the end of 2012.

What I am doing in the meantime is using a WebView with loadData(), and passing in an IFrame as stated on the YoUTube API page. The Iframe is quite limited (most parameters don't even work, like controls=0), so if you need more flexibility like controlling the view then use the JavaScript API and then embed the JavaScript in the HTMl you pass into loadData.

I tried the Media Controller and couldn't get it to work, even though YouTube use it in there own app.

The other thing to try which i didn't get around to. Is to use the google search apis. You can specify a YouTube video and it will give you the URL's to the thumbnails, videos etc. This way you can get to the raw files (www.youtube.com/...../..../myfile.3gp) rather than calling a webpage. These might then be loadable in the MediaController.

Kurtis Nusbaum

If you know what video you want to view, you could just create an Intent with the url in it and use that to launch the Youtube app. You can see this SO Post for more details.

you can simply use youtube rtsp link in videoview as:

    String myurl="rtsp://v4.cache4.c.youtube.com/CjYLENy73wIaLQk_ezfHQ9mvqRMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYN-__7O28NSPUAw=/0/0/0/video.3gp";     

        Uri video = Uri.parse(myurl);
        mVideoView = new VideoView(this);           
        mVideoView.setVideoURI(video);
        myMediaController = new MediaController(this);

it works simply for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!