How to auto play iframe youtube on webview android

前端 未结 7 504
不知归路
不知归路 2021-01-19 00:52

I use android webview in my app for display video from youtube it\'s work well.

But i want it\'s auto play.

This is my activity i append \"?autoplay=

相关标签:
7条回答
  • 2021-01-19 01:55

    Do like this. Hope it helps

    String html = "<iframe class=\"youtube-player\" style=\"border: 0; width: 100%; height: 95%; padding:0px; margin:0px\" id=\"ytplayer\" type=\"text/html\" src=\"http://www.youtube.com/embed/"
                    + "J2fB5XWj6IE?autoplay=1"
                    + "&fs=0\" frameborder=\"0\">\n"
                    + "</iframe>\n";
    

    From below link

    In Chrome, autoplay is also disabled

    (https://code.google.com/p/chromium/issues/detail?id=159336)

    I believe the same happens with the recent versions of the default Android Web Browser.

    0 讨论(0)
提交回复
热议问题