2017-10-09 94 views
0

我有webview顯示在自定義對話框中,我加載了一個URL到WebView這是視頻URL,默認情況下視頻加載並開始播放,我想禁用自動播放功能。這裏是我的代碼WebView無法禁用自動播放視頻從WebView的URL

wvActiveVideo.setWebViewClient(new WebViewClient()); 
       wvActiveVideo.getSettings().setJavaScriptEnabled(true); 
       wvActiveVideo.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); 
       wvActiveVideo.getSettings().setPluginState(WebSettings.PluginState.ON); 
       wvActiveVideo.getSettings().setMediaPlaybackRequiresUserGesture(false); 
       wvActiveVideo.setWebChromeClient(new WebChromeClient()); 
       wvActiveVideo.setWebViewClient(new WebViewClient()); 
       wvActiveVideo.getSettings().setSupportZoom(true); 
       wvActiveVideo.getSettings().setBuiltInZoomControls(true); 
       wvActiveVideo.getSettings().setDisplayZoomControls(false); 
       String url = model.getVideo(); 
       wvActiveVideo.loadUrl(model.getVideo()); 
+0

希望此鏈接將幫助您 https://stackoverflow.com/questions/5946698/how-to-stop-youtube-video-playing-in-android-webview –

+0

thanx的評論,但我使用自定義對話框,我有webview – YoLo

回答

0

這取決於你的算法。

第一條建議,在加載url之前顯示你的用戶播放按鈕的背景。

第二個建議是數據處理;

@Override 
     public void onPageFinished(WebView view, String url) { 

       view.loadUrl("javascript:document.getElementById(\"video-test\").innerHTML = \"\";void(0);"); 
       webView.setVisibility(View.VISIBLE); 

     } 
+0

播放按鈕顯示在背景中我想停止它的自動播放,因爲頁面完成其加載視頻 – YoLo

+0

okey向我們展示您的代碼思考它? – mbakgun