|
附上一个完整的demo,这个demo是要使用openFrame打开这个页面,使用openWin会失败,希望有大神能帮我看一下iOS为什么会闪退?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>视频下载</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
width: 100%;
}
#wrap {
height: 100%;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-webkit-flex-flow: column;
flex-flow: column;
background-color: #f8f8f8;
}
#header {
position: relative;
text-align: center;
background-color: #f08519;
color: #fff;
width: 100%;
line-height: 44px;
font-size: 17px;
}
#header h1 {
font-size: 20px;
height: 44px;
line-height: 44px;
margin: 0;
color: #fff;
}
#main {
text-align: center;
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
padding: 2em;
background-color: #fff;
}
#footer {
position: relative;
height: 50px;
line-height: 50px;
color: #666;
background-color: #f8f8f8;
width: 100%;
text-align: center;
}
.btn {
margin-top: 20px;
background-color: #f08519;
line-height: 50px;
border-radius: 5px;
color: #fff;
}
.progress-text {
margin-top: 20px;
line-height: 30px;
}
.progress-percent {
margin-top: 20px;
height: 2px;
background-color: #f08519;
}
</style>
</head>
<body>
<div id="wrap">
<div id="header">测试视频播放</div>
<div id="main">
<div class="btn" onclick="api.closeFrame();">关闭frame</div>
<div class="btn" onclick="download();">下载视频</div>
<div class="progress-text" id="text" hidden>0%</div>
<div class="progress-percent" id="percent" hidden></div>
</div>
<div id="footer" onclick="location.reload();">刷新页面</div>
</div>
<script src="http://cdn**.**/jquery/2.1.4/jquery.min.js"></script>
<script>
apiready = function (){
};
var fileName = 'test333.mkv';
var url = 'http://mobiledev**.**/uploads/' + fileName;
function download(){
api.download({
url: url,
savePath: 'fs://download/' + fileName,
report: true,
cache: true,
allowResume: true
}, function (downloadRet, downloadErr){
$('#text').html(downloadRet.percent + '%').show();
$('#percent').css('width', downloadRet.percent + '%').show();
if (parseFloat(downloadRet.percent) == 100) {
api.confirm({
msg: '下载完成,点击查看',
buttons: ['取消', '确定']
}, function (confirmRet, confirmErr){
if (confirmRet.buttonIndex == 2) {//点击确定
var obj = api.require('polyVideo');
try {
obj.open({
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: 240
},
//vid: '02d7f2dc232a2760e985d3dae7d3f936_0',
path: downloadRet.savePath,
autoPlay: true,
fixedOn: api.frameName,
fixed: false
}, function (ret1, err1){
});
} catch (e) {
alert(JSON.stringify(e))
}
}
});
}
});
}
</script>
</body>
</html> |
|