[TIMOB-16105] Android: Second time a webview is loaded with a HTML5 video the video does not play
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.2.0 |
Fix Version/s | n/a |
Components | Android |
Labels | 3.2.0, android, api19, webview |
Reporter | Wienke |
Assignee | Unknown |
Created | 2013-12-27T15:57:42.000+0000 |
Updated | 2018-02-28T20:04:11.000+0000 |
Added this youtube video showing the actual result: http://www.youtube.com/watch?v=0MpSpfJNyOk
I did some more research and it seams that the WebView is not destroyed completely upon leaving the activity. I am currently playing around with adding things like this to the onDestroy function in the WebViewProxy: nativeWebView.stopLoading(); nativeWebView.removeAllViews(); nativeWebView.clearHistory(); nativeWebView.clearCache(true); nativeWebView.loadUrl("about:blank"); nativeWebView.pauseTimers(); //new code nativeWebView.destroy(); nativeWebView = null; When trying this no webview is shown at all on opening it for a second time.
Ok, I got one step further. When adding some javascript which pauses the video to the onPause method it works: @Override public void onPause(Activity activity) { evalJS("document.getElementsByTagName('video')[0].pause();"); // <--- this one pause(); } I would say this is a very ugly hack and we should investigate further on why pausing the video makes the solution. Is there a way in Android where a global playback state is kept? Can this be altered? Update: Just tested this on a bigger project with more than just the webview in the activity. And it does not work. Somehow it does not wait for the javascript to finish completely.
[~wgiezeman], maybe your hack works better if you not rely on the external onPause event, but rather use
evalJS
upon loading the view to insert an event listener in the web view that pauses the video when it looses focus? But of course a more solid non-hack to resolve this ticket is still needed.[~wgiezeman] Thank you very much for providing the detailed information and a video clip to reproduce the problem. We can now reproduce this problem in-house albeit inconsistently. Moving this ticket to engineering for further evaluation and prioritization.
[~ragrawal] Thanks for addressing this issue so quickly. I will continue with researching the issue as well. If I can help in any way please let me know.
I spend 50 points on a bounty on this question and the answer seems quite interesting: http://stackoverflow.com/questions/20379478/android-samsung-s4-html5-video-pauses What do you think?
I tested it the solution on stackoverflow: http://stackoverflow.com/questions/20379478/android-samsung-s4-html5-video-pauses And it is exactly the right way to solve this problem: I modified the code a bit:
So white is the PR Wienke? ;)
;) I think putting in like this in the SDK is not the way to go. A good way to go would be adding the Audiomanager to the API so it can be controlled upon closing the activity. But that is up to the Appcelerator guys.