我正在全屏播放html的视频.当我点击全屏按钮在视频方法onShowCustomView被触发.这是我的实现:
public void onShowCustomView(View view, CustomViewCallback callback) {
super.onShowCustomView(view, callback);
if (view instanceof FrameLayout) {
customComponenet.addView(view, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
Gravity.CENTER));
customComponenet.setVisibility(View.VISIBLE);
}
}
其中customComponenet是FrameLayout放在我当前的布局之上. Wideo玩得很好,它的可见性和一切接缝都可以,但它会抛出:
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): FATAL EXCEPTION: main
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): java.lang.NullPointerException
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoFullScreen.switchProgressView(HTML5VideoFullScreen.java:320)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoView.setPlayerBuffering(HTML5VideoView.java:319)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoView.start(HTML5VideoView.java:85)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoViewProxy$VideoPlayer.onPrepared(HTML5VideoViewProxy.java:257)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoViewProxy.onPrepared(HTML5VideoViewProxy.java:278)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoView.onPrepared(HTML5VideoView.java:265)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.webkit.HTML5VideoFullScreen.onPrepared(HTML5VideoFullScreen.java:164)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1456)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.os.Handler.dispatchMessage(Handler.java:99)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.os.Looper.loop(Looper.java:132)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at android.app.ActivityThread.main(ActivityThread.java:4028)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at java.lang.reflect.Method.invokeNative(Native Method)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at java.lang.reflect.Method.invoke(Method.java:491)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-27 22:16:07.520: ERROR/AndroidRuntime(7235): at dalvik.system.NativeStart.main(Native Method)
我究竟做错了什么?
我的WebView设置:
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(PluginState.ON);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setDatabasePath("/data/data/" + App.class.getPackage().getName() + "/databases");
webView.getSettings().setSupportZoom(false);
我正在测试Galaxy Tab 10.1,默认浏览器这是正常工作.我可以切换到全屏.此外,在我的应用程序中,当我播放视频嵌入,我只能听到声音,并看到视频应该在区域下方的状态栏,而在浏览器我可以看到视频嵌入在WebView和全屏.
编辑
这里的https://github.com/novemberox/VideoFail这个样例项目带有这个错误,你可以在仿真器上打开它,所以你不需要有真正的设备.