i***@163.com
i***@163.com
  • 发布:2019-05-29 12:07
  • 更新:2019-06-12 11:49
  • 阅读:1505

【报Bug】ios真机 h5+ audio 背景播放bug

分类:HTML5+

详细问题描述

uniapp项目,使用h5+ audioplayer,配置有背景播放选项,首次播放延迟大概6秒钟

[内容]

重现步骤

[步骤]

1.进入播放页面

  1. 播放器随着页面onload初始化
  2. 马上点击播放按钮
  3. 观察ios状态栏播放器,已经播放,但是没有声音
  4. 等待大概6秒钟
  5. 播放器从头开始播放,此时有声音

[结果]
前6秒在播放但是没有声音,然后从头开始播放,一切正常
[期望]
不要前6秒的延迟

IDE运行环境说明

[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]

[IDE版本号]
hbuilderx 1.9.9
[windows版本号]
win10
[mac版本号]

uni-app运行环境说明

[运行端是h5或app或某个小程序?]
ios真机
[运行端版本号]

1.9.9

[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]

hbuilderx创建的uniapp项目

[编译模式是老模板模式还是新的自定义组件模式?]

自定义组件模式,并且ios配置有 "UIBackgroundModes" : [ "audio" ]

App运行环境说明

[Android版本号]

[iOS版本号]
12.1.4(16D57)
[手机型号]
iphone6
[模拟器型号]
真机

附件

[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]

[App安装包或H5地址]
https://fir.im/brandmaxtestios?release_id=5cee001a548b7a6fb6112192
[可重现代码片段]

<template>
<view class="content">
<button @tap="play" type="default" class="login-btn">播放</button>
<button @tap="pause" type="default" class="login-btn">暂停</button>
<button @tap="info" type="default" class="login-btn">状态</button>
<view style="width: 100%;" v-for="(devitem,devitemindex) in devmsg" :key="devitemindex">
<text>方法:{{devitem.method}}</text>
<text v-show="devitem.msg">消息:{{devitem.msg}}</text>
</view>
</view>
</template>

<script>
export default {
data() {
return {
srcList: [],
player:undefined,
devmsg: []
}
},
onLoad() {
this.palyer = plus.audio.createPlayer({
"autoplay": false,
"title": "title",
"coverImgUrl": "http://113.108.157.90:8088/resource/lesson/1558853548932.jpg",
"backgroundControl": true,
"epname":"epname",
"singer": "singer",
"src": "http://113.108.157.90:8088/resource/lesson/mp3/lesson/1558853662545.mp3",
"startTime": 0,
"volume": 1,
})
this.palyer.addEventListener("canplay",this._onCanplay);
this.palyer.addEventListener("play",this._onPlay);
this.palyer.addEventListener("pause",this._onPause);
this.palyer.addEventListener("stop",this._onStop);
this.palyer.addEventListener("ended",this._onEnded);
this.palyer.addEventListener("error",this._onError);
this.palyer.addEventListener("waiting",this._onWaiting);
this.palyer.addEventListener("seeking",this._onSeeking);
this.palyer.addEventListener("seeked",this._onSeeked);
},
methods: {
addDevMsg(methodname, msg) {
this.devmsg.push({
"method": methodname,
"msg": msg
})
},
play(){
this.palyer.play();
},
pause(){
this.palyer.pause();
},
resume(){

        },  
        stop(){  

        }  
        ,  
        seekTo(){  

        },  
        info(){  
            this.addDevMsg('info()',"getBuffered:"+this.palyer.getBuffered()+","+"getDuration:"+this.palyer.getDuration()+","+"getPosition:"+this.palyer.getPosition()+","+"isPaused:"+this.palyer.isPaused())  
        },  
        _onCanplay(){  
            this.addDevMsg('_onCanplay()')  
        },_onPlay(){  
            this.addDevMsg('_onPlay()')  
        },_onPause(){  
            this.addDevMsg('_onPause()')  
        },_onStop(){  
            this.addDevMsg('_onStop()')  
        },_onEnded(){  
            this.addDevMsg('_onEnded()')  
        },_onError(){  
            this.addDevMsg('_onError()')  
        },_onWaiting(){  
            this.addDevMsg('_onWaiting()')  
        },_onSeeking(){  
            this.addDevMsg('_onSeeking()')  
        },_onSeeked(){  
            this.addDevMsg('_onSeeked()')  
        }  
    }  
}  

</script>

联系方式

[QQ]

123905778

2019-05-29 12:07 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

试试hello uni-app里面的示例有没有这个问题?

  • i***@163.com (作者)

    官方例子中的代码拿下来,把音频换成时间长一些的,20分钟或者30分钟就会出现这个问题.

    2019-05-29 13:32

  • i***@163.com (作者)

    h5+的audioplayer,uni的背景播放器都试过了,都是有这个bug

    2019-05-29 13:59

DCloud_iOS_XHY

DCloud_iOS_XHY

你好
1.延时问题是因为播放网络音频会有缓存的过程,缓存一定数据后才会开始播放;
2.缓存过程中控制页面得进度条在走,这个问题需要排查一下

  • i***@163.com (作者)

    如果配置后台播放就有这个bug,如果不配置后台播放,就没这个bug

    2019-05-30 15:26

DCloud_iOS_XHY

DCloud_iOS_XHY

HBuilderX 2.0.0 版本已发布,请更新使用

i***@163.com

i***@163.com (作者) - 全债程序猿

感谢大佬

该问题目前已经被锁定, 无法添加新回复