How to play Youtube videos in Android Video View?

后端 未结 8 1437
[愿得一人]
[愿得一人] 2020-12-02 14:24

I am developing an android application which requires a youtube video player embedded within it. I successfully got the RTSP video URL from the API, but while trying to load

8条回答
  •  误落风尘
    2020-12-02 14:59

    As I can't find any way to load the rtsp URL in video view (for all devices & android versions), I solved my problem with another work around. I used a webview to embed the youtube player within it, and this method working nicely in all tested devices.

    Here is my code:

    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginState(PluginState.ON);
    mWebView.loadUrl("http://www.youtube.com/embed/" + videoID + "?autoplay=1&vq=small");
    mWebView.setWebChromeClient(new WebChromeClient());
    

    Thank you very much for all your help guys.

提交回复
热议问题