webview视频(iframe)不播放,除非声音被静音

h43kikqp  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(334)

我尝试在android java中使用webview播放iframe视频,视频加载正确,但除非声音静音,否则拒绝播放。请帮忙。这是我的网络视图代码:

private void playVideoOnWebView(String videoUrl) {
        videoWebViewPlayer = findViewById(R.id.videoPlayerWebView);           
        videoWebViewPlayer.setVisibility(VISIBLE);
        videoWebViewPlayer.getSettings().setJavaScriptEnabled(true);    
        videoWebViewPlayer.getSettings().getAllowContentAccess();
        videoWebViewPlayer.getSettings().setDomStorageEnabled(true);
        videoWebViewPlayer.getSettings().setAppCacheEnabled(true);videoWebViewPlayer.getSettings().setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/cache");
        videoWebViewPlayer.getSettings().setDatabaseEnabled(true);
        videoWebViewPlayer.getSettings().setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/databases");
        videoWebViewPlayer.getSettings().setPluginState(WebSettings.PluginState.ON);
        videoWebViewPlayer.getSettings().setDomStorageEnabled(true);
        videoWebViewPlayer.setWebChromeClient(new WebChromeClient());
        videoWebViewPlayer.loadUrl(videoUrl);
    }

这是网页上的iframe

<iframe id="iframe" style="width: 100%; border-width: 0px; height: 100%;" src="https://player.vimeo.com/video/259666821?loop=false&amp;byline=false&amp;portrait=false&amp;title=false&amp;speed=true&amp;transparent=1&amp;gesture=media" allowfullscreen="" allowtransparency="" allow="autoplay"></iframe>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题