iOS应用程序冻结,在webview中加载视频时不会崩溃 我有一个iPad应用程序,开发了一个叫做OpenPoP的第三方工具,它把AS3转换成C++,然后从出口到iOS。(我只是想指出,这不是一个在XCode中使用Obj-C的“本机”应用程序,我是在AS3中编写的)

iOS应用程序冻结,在webview中加载视频时不会崩溃 我有一个iPad应用程序,开发了一个叫做OpenPoP的第三方工具,它把AS3转换成C++,然后从出口到iOS。(我只是想指出,这不是一个在XCode中使用Obj-C的“本机”应用程序,我是在AS3中编写的),ios,html,video,safari,Ios,Html,Video,Safari,现在我有了这个iPad应用程序,它以幻灯片的形式显示图片和视频。对于视频,我使用一个WebView加载一个HTML页面,在该页面中,我将视频对象的src属性更改为下载到应用程序存储器中的视频文件的位置。除了应用程序在运行几个小时(3-6小时)时冻结外,它工作正常 我搜索了这个问题,并尝试了解决方案,但这似乎并没有改变我的任何东西 由于应用程序冻结(就在HTML页面需要加载视频之前),并且不会崩溃,这意味着什么?我需要销毁视频对象吗?首先,我为每个视频创建了一个新的WebView,但现在我正在重用

现在我有了这个iPad应用程序,它以幻灯片的形式显示图片和视频。对于视频,我使用一个WebView加载一个HTML页面,在该页面中,我将视频对象的src属性更改为下载到应用程序存储器中的视频文件的位置。除了应用程序在运行几个小时(3-6小时)时冻结外,它工作正常

我搜索了这个问题,并尝试了解决方案,但这似乎并没有改变我的任何东西

由于应用程序冻结(就在HTML页面需要加载视频之前),并且不会崩溃,这意味着什么?我需要销毁视频对象吗?首先,我为每个视频创建了一个新的WebView,但现在我正在重用WebView,只是更改了src属性,但这对我也没有帮助

有人能解释一下吗?OpenPlug已经停止了it服务,不再提供任何支持,但我认为这更像是iPad上的网络视图/视频问题(?)

需要注意的是:应用程序是冻结的,但我的iPad不是。应用程序不会生成崩溃报告,也不会再执行任何代码(也没有跟踪)。当我按下iPad上的Home(主页)按钮并按下应用程序图标时,应用程序将重新启动

下面是我的HTML页面的代码,每当需要启动新视频时,该页面都会刷新(webview.location=…)


函数VideoEndHandler(){
var video=document.getElementById(“视频播放器”);
video.src=“”;
video.load();
window.location.hash=“结束”;
}
函数videoErrorHandler(){
window.location.hash=“错误”;
var video=document.getElementById(“视频播放器”);
video.src=“”;
video.load();
}
var回路;
函数设置(){
var video=document.getElementById(“视频播放器”);
video.addEventListener(“错误”,videoErrorHandler,false);
video.addEventListener(“结束”,VideoEndHandler,false);
video.load();
video.play();
startHashLoop();
}
函数startHashLoop(){
if(window.location.hash==“#接触”){
setAsPaused();
}
if(window.location.hash==“#暂停”){
//检查图像
testImage(“shouldResume.png?nocache=“+Math.random());
}
if(window.location.hash==“#resume”){
var video=document.getElementById(“视频播放器”);
video.play();
}
loop=setTimeout(hashLoop,500);
}
函数测试图像(url){
var img=新图像;
img.addEventListener(“加载”,即良好);
img.addEventListener(“错误”,是坏的);
img.src=url;
}
函数isGood(){
window.location.hash=“resume”;
}
函数isBad(){
//警报(“图像不存在”);
}
函数hashLoop(){
startHashLoop();
}
函数setAsTouched(){
window.location.hash=“已触摸”;
}
函数setAsPaused(){
var video=document.getElementById(“视频播放器”);
video.pause();
window.location.hash=“暂停”;
}

如果您发布完整的代码,这会很有帮助,但我认为这是冻结的,因为您正在主线程中从web加载视频,这也负责重新绘制UI。通过在线程中加载大型视频,UI也会冻结


我建议将用于视频加载的代码移动到单独的线程中(如果您在iOS5上,请使用块)。

因此,概括地说,“我的应用程序冻结”。显示代码或没有人可以帮助您。HTML页面的代码被添加。我还想知道为什么应用程序冻结而不是崩溃?知道有什么区别吗?有人能帮我吗?我有更多的信息:视频冻结,即使有足够的内存可用,所以它不是一个内存问题,但出于某种原因,视频冻结后,我的应用程序运行约8至9小时。这段视频以前播放过,所以我不知道它可能是什么,有人吗?请显示加载此网页的代码
<html>
    <head>
        <script>
            function videoEndedHandler(){
                var video = document.getElementById("videoPlayer");
                video.src = "";
                video.load();
                window.location.hash = "ended";
            }

            function videoErrorHandler(){
                window.location.hash = "error";
                var video = document.getElementById("videoPlayer");
                video.src = "";
                video.load();
            }

                                    var loop;
                                    function setup(){
                                        var video = document.getElementById("videoPlayer");
                                        video.addEventListener("error", videoErrorHandler,false);
                                        video.addEventListener("ended", videoEndedHandler,false);
                                        video.load();
                                        video.play();
                                        startHashLoop();
                                    }

                                    function startHashLoop(){
                                        if(window.location.hash == "#touched"){
                                            setAsPaused();
                                        }

                                        if(window.location.hash == "#paused"){
                                            //check image
                                            testImage("shouldResume.png?nocache=" + Math.random());
                                        }


                                        if(window.location.hash == "#resume"){
                                            var video = document.getElementById("videoPlayer");
                                            video.play();
                                        }

                                        loop = setTimeout(hashLoop,500);
                                    }

                                    function testImage(url) {
                                        var img = new Image;
                                        img.addEventListener("load",isGood);
                                        img.addEventListener("error",isBad);

                                        img.src = url;
                                    }

                                    function isGood() {
                                        window.location.hash = "resume";
                                    }

                                    function isBad() {
                                        //alert("Image does not exist");
                                    }


                                    function hashLoop(){
                                        startHashLoop();
                                    }

                                    function setAsTouched(){
                                        window.location.hash = "touched";
                                    }

                                    function setAsPaused(){
                                        var video = document.getElementById("videoPlayer");
                                        video.pause();
                                        window.location.hash = "paused";
                                    }
                                    </script>
    </head>

    <body onload="setup();" style="background-color:#000000;">
    <a href="javascript:setAsTouched()" style="top:0;left:0;position:absolute;z-index:1;color:#FF0000;border:0px solid red;width:100%;height:100%;display:block;"></a>
        <video id="videoPlayer" style="top:0;left:0;position:absolute;" width="100%" height="100%" preload="auto" src="##VIDEO_URL##" autoplay="autoplay" webkit-playsinline />

    </body>
</html>