打开一个活动包含了第二次一HTML5视频网页视图 [英] Opening an activity with a webview containing a HTML5 video for a second time

查看:328
本文介绍了打开一个活动包含了第二次一HTML5视频网页视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供视频的使用Appcelerator的钛Android中网页视图。在iOS这个工程就像一个魅力。但是,在Android这给了一些问题。这不顺心的活动被打开与持有HTML5视频元素的网页视图的第二次。

I am serving video's in a webview in Android using Appcelerator Titanium. On iOS this works like a charm. But on Android this gives some problems. It goes wrong the second time an activity is opened with a webview that holds a html5 video element.

重现步骤:

(另见本YouTube视频: http://www.youtube.com/watch?v = 0MpSpfJNyOk

(Also see this youtube video: http://www.youtube.com/watch?v=0MpSpfJNyOk )

第一次打开与HTML5视频的视频/活动它显示的视频,我能够发挥它。当我关闭窗口/活动,并打开一个新的窗口,与其他视频的WebView负载和HTML5视频播放的负载为好。但玩它是不可能的。当pressing全屏按钮和pressing播放/暂停按钮两次的视频开始在全屏播放。

The first time opening a video/activity with html5 video it shows the video and I am able to play it. When I close the window/activity and open a new window with another video the webview loads and the html5 video play loads as well. But playing it is not possible. When pressing the fullscreen button and pressing the play/pause button twice the video begins to play in fullscreen.

在关闭活动/窗口中的影片,在未来的窗口前,暂停视频可以播放。

When pausing the video before closing the activity/window the video in the next window is able to play.

在YouTube视频显示使用这个测试项目的 https://dl.dropboxusercontent.com/u/1849335/WebviewTest.zip

The youtube video shows the behavior on a Samsung Galaxy Tab 3 10.1" running Android 4.2 using this test project https://dl.dropboxusercontent.com/u/1849335/WebviewTest.zip

您能理解我花了一段时间来理解这个模式:)

You can understand it took me a while to understand this pattern :)

上下文:

我使用的是钛3.2.GA SDK此修复程序( https://github.com / Appcelerator的/ titanium_mobile /拉/ 5150 )合并。在这种变化,他们固定了的onPause()方法应始终在网页视图关闭活动时,否则插件进程将继续发挥调用。

I am using the 3.2.GA Titanium SDK with this fix (https://github.com/appcelerator/titanium_mobile/pull/5150) merged. In that change they fixed that the onPause() method should always be called on the webview when closing a activity otherwise the plugin processes will continue to play.

这是负责这一行为的文件有:
<一href=\"https://github.com/wienke/titanium_mobile/tree/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview\" rel=\"nofollow\">https://github.com/wienke/titanium_mobile/tree/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview
<一href=\"https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java\" rel=\"nofollow\">https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java

The files that are responsible for this behavior are: https://github.com/wienke/titanium_mobile/tree/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java

好奇,如果人们还没有看到钛此行为。

Curious if people also see this behavior without Titanium.

推荐答案

该解决方案在这一问题最终被提供了:

The solution was eventually provided in this question:

的Andr​​oid(三星S4)HTML5视频暂停

添加此:

pause();
((AudioManager)activity.getSystemService(
                activity.AUDIO_SERVICE)).requestAudioFocus(
                        new OnAudioFocusChangeListener() {
                            @Override
                            public void onAudioFocusChange(int focusChange) {}
                        }, AudioManager.STREAM_MUSIC, 
                        AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

该SDK的onPause方法在这里:

to the SDK onPause method here:

<一个href=\"https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java#L427\" rel=\"nofollow\">https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java#L427

解决了这一问题。

我提交了一份缺陷Appcelerator的。希望他们在不久的SDK包括此。

I filed a defect to Appcelerator. Hope they include this soon in their SDK.

这篇关于打开一个活动包含了第二次一HTML5视频网页视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆