我正在使用HTML video tag
在 android Webview 中播放视频。但是,当我尝试按下全屏按钮时,onShowCustomView()
仅第一次调用 from webview chrome 客户端。每次我按下全屏按钮时,onShowCustomView()
都不会调用该函数。
我想要的是,每次按下全屏按钮时,都应该调用 onShowCustomView()。
网页浏览
webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setAppCacheEnabled(true);
webView.setWebChromeClient(mClient);
webView.setWebViewClient(new WebViewClient());
HTML 视频标签
<div>
<!--<img id="videoImage" src="img/UI_homepage_innovation.png" style="cursor:pointer" onclick="play()"/>
<iframe id="video" style="display:none;" src="http://www.youtube.com/embed/SNMjzPRQUA8?modestbranding=1&rel=0&showinfo=0&autohide=1&fs=0&autoplay=1" frameborder="0" #allowfullscreen></iframe>-->
<video poster="img/UI_homepage_innovation.png" controls>
<source src="video/sintel.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
Webview Chrome 客户端
public class MyChromeClient extends WebChromeClient {
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
Log.v("Testing", "onShowCustomView");
}
@Override
public void onHideCustomView() {
Log.v("Testing", "onHideCustomView");
}
}