Home  >  Q&A  >  body text

android WebView 无法播放视频

项目中需要使用android webview 加载视频。
已经开启activity的硬件加速,已经打开javascript。但是加载视频是始终loading状态。如下图

求解答方案。不要推荐腾讯浏览器内核SDK ^_^

PHP中文网PHP中文网2720 days ago862

reply all(3)I'll reply

  • 迷茫

    迷茫2017-04-18 09:15:56

    Used Tencent X5 browser to solve the problem

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:15:56

    Add the settings of the following two lines of code to play online videos! Remember to give me the best answer! !

    if (Build.VERSION.SDK_INT < 8) {

     webview.getSettings().setPluginsEnabled(true);  

    } else {

     webview.getSettings().setPluginState(PluginState.ON);

    }

    if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.LOLLIPOP) {
    webview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:15:56

    1. Use a browser to check whether there is a problem with the video playback. If there is a problem, it is caused by the video.
    2. After the first step is executed, check whether the settings of the webView are complete. The specific code can be referred to upstairs.

    reply
    0
  • Cancelreply