详细问题描述
(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)
[内容]
在app中创建了一个backgroundAudioManager对象,paused属性永远返回true
重现步骤
[步骤]
1.创建backgroundAudioManager对象
2.赋值src,播放
3.调用backgroundAudioManager.paused
[结果]
返回true
[期望]
1.背景音乐播放时返回false
2.背景音乐暂停或停止时返回true
[如果语言难以表述清晰,拍一个视频或截图,有图有真相]
IDE运行环境说明
[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]
[IDE版本号]
HBuilderX 2.0.1.20190614
[windows版本号]
win 10
[mac版本号]
uni-app运行环境说明
[运行端是h5或app或某个小程序?]
app
[运行端版本号]
2.0.1
[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]
[编译模式是老模板模式还是新的自定义组件模式?]
App运行环境说明
[Android版本号]
9
[iOS版本号]
[手机型号]
荣耀v9
[模拟器型号]
附件
[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]
[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]
<template>
<view class="content">
<button @tap="play" type="default" class="login-btn">播放</button>
<button @tap="replace" type="default" class="login-btn">切换</button>
<button @tap="pause" type="default" class="login-btn">暂停</button>
<button @tap="player.play()" type="default" class="login-btn">暂停后播放</button>
<button @tap="info" type="default" class="login-btn">状态</button>
<button @tap="devmsg=[]" 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() {
// #ifndef H5
this.player = uni.getBackgroundAudioManager()
// #endif
// #ifdef H5
this.player = uni.createInnerAudioContext();
// #endif
this.player.onPlay(this._onPlay);
this.player.onCanplay(this._onCanplay);
this.player.onPause(this._onPause);
this.player.onStop(this._onStop);
this.player.onEnded(this._onEnded);
this.player.onWaiting(this._onWaiting);
},
methods: {
replace(){
this.player.src = "http://learning.inno-vision.cn/resource/lesson/mp3/lesson/1559993865931.mp3";
this.player.title="title2";
this.player.epname="epname2";
this.player.autoplay=true;
this.player.singer="singer2";
this.player.coverImgUrl="http://learning.inno-vision.cn/resource/lesson/1560243353526.jpg";
console.log(this.player.src)
},
addDevMsg(methodname, msg) {
this.devmsg.push({
"method": methodname,
"msg": msg
})
},
play(){
this.player.src = "http://113.108.157.90:8088/resource/lesson/mp3/lesson/1558853662545.mp3";
this.player.title="title";
this.player.autoplay=true;
this.player.epname="epname";
this.player.singer="singer";
this.player.coverImgUrl="http://113.108.157.90:8088/resource/lesson/1558853548932.jpg";
this.player.play();
},
pause(){
this.player.pause();
},
resume(){
},
stop(){
}
,
seekTo(){
},
info(){
this.addDevMsg('info()',"paused:"+this.player.paused)
},
_onCanplay(){
this.addDevMsg('_onCanplay()')
},_onPlay(){
this.addDevMsg('_onPlay()','调用paused:'+this.player.paused)
},_onPause(){
this.addDevMsg('_onPause()','调用paused:'+this.player.paused)
},_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>
[App安装包或H5地址]
[可重现代码片段]
,_onPlay(){
this.addDevMsg('_onPlay()','调用paused:'+this.player.paused)
},_onPause(){
this.addDevMsg('_onPause()','调用paused:'+this.player.paused)
}
联系方式
[QQ]
123905778