Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable interaction with html5 videos in webview or properly catch their exceptions?

I have app with webview and I use ACRA. I receive crash reports from users with errors caused by interaction with HTML5Video.

Error 1:

"java.lang.NullPointerException
    at android.webkit.HTML5VideoViewProxy$VideoPlayer.exitFullScreenVideo(HTML5VideoViewProxy.java:180)
    at android.webkit.HTML5VideoViewProxy.exitFullScreenVideo(HTML5VideoViewProxy.java:770)
    at android.webkit.WebViewClassic$PrivateHandler.handleMessage(WebViewClassic.java:7422)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5039)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)"

Error 2:

"java.lang.NullPointerException
    at android.webkit.HTML5VideoFullscreen.switchProgressView(HTML5VideoFullscreen.java:455)
    at android.webkit.HTML5VideoView.enterFullscreenVideoState(HTML5VideoView.java:546)
    at android.webkit.HTML5VideoViewProxy$VideoPlayer.enterFullscreenVideo(HTML5VideoViewProxy.java:182)
    at android.webkit.HTML5VideoViewProxy.handleMessage(HTML5VideoViewProxy.java:479)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:155)
    at android.app.ActivityThread.main(ActivityThread.java:5485)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
    at dalvik.system.NativeStart.main(Native Method)"

Here are my DropBox logs if needed:

for error 1: http://pastebin.com/w8G1UJvG

seems to be interesting:

11-14 22:19:29.912 E/libEGL  (14744): call to OpenGL ES API with no current context (logged once per thread)
11-14 22:19:29.917 W/dalvikvm(14744): threadid=1: thread exiting with uncaught exception (group=0x40d4a2d0)

for error 2: http://pastebin.com/8BEK1vAm

seems to be interesting:

12-10 00:14:52.542 W/YourLogTag(24823): Couldn't find activity to view mimetype: video/x-m4v

In fact I even don't suggest interaction with HTML5 videos in my webview. I guess, users open them from pages, interaction with which is also not provided. Also I think it's a bad way to try to prohibit users interaction with other webpages (and it may be really hard in case of my app). But also, user definetely don't experience a warm feeling to my app, when crash dialog appears before him...

So I want to block users' interaction with HTML5 Video in my webview or just catch exceptions properly (seems to be not very good approach). What's the best way to do it?

Here are my webview settings, if they're required:

webView.getSettings().setJavaScriptEnabled(false);
webView.getSettings().setUserAgentString("Some user agent"); 
like image 417
janot Avatar asked Dec 16 '12 15:12

janot


People also ask

What is WebViewClient?

WebViewClient is the object responsible for most the actions inside a WebView. JavaScript enabled, security, routing, etc. You can make a custom one, as well as use a Chrome one.

How do I stop WebView from loading on Android?

stopLoading will stop the current load.

How do I close WebView?

Add a close button and on its click set: webview. setVisibility(View. INVISIBLE); webview.


1 Answers

Unfortunately I'm not going to be able to provide a direct answer, however, I did find an interesting post that spurred a lot of conversation. WebView and HTML5 Video

It's an old question but you'll notice that as time went on, newer and newer answers were posted that allowed HTML5 video to work. Hopefully reading some of those answers will get you on the right track and ultimately get it working for you.

I also found an open-source project which fixed the issue for you...however it's old and doesn't work for 4.0 and up. HTML5 WebView

like image 56
Jay Soyer Avatar answered Oct 24 '22 06:10

Jay Soyer