收藏
回答

InnerAudioContext中pause不执行,pause的属性值不更新

框架类型 问题类型 操作系统 工具版本
小程序 Bug Windows v1.02.1811150

- 当前 Bug 的表现(可附上截图)



- 预期表现

使用InnerAudioContext.paused属性值判断播放状态,然后更改为与当前状态相反的状态(即当目前为play状态,那么就修改为pause状态,当前状态由paused属性值判定)

- 复现路径


- 提供一个最简复现 Demo

wxml

<!--pages/play/play.wxml-->

<view class='body'>

<view class='info'>

<view class='song'>

{{songName}}

</view>

<view class='singer'>

{{singer}}

</view>

</view>

<view class='top'>

<image src='{{img_url}}'></image>

</view>

<view class='ctl'>

<image class='random' src='../../images/images/random.png'></image>

<image class='left' bindtap='clickPreviousMusic' src='../../images/images/left.png'></image>

<image class='mid' bindtap='clickPlayButt' src='{{play_butt_icon_url}}'></image>

<image class='right' bindtap="clickNextMusic"  src='../../images/images/right.png'></image>

<image class='list' src='../../images/images/menu.png'></image>

</view>

</view>


js

// pages/play/play.js

let music = wx.createInnerAudioContext();

let data = {

1: {

"url": "http://www.ytmp3.cn/down/52104.mp3",

"songName": "告白气球",

"singer": "周杰伦",

"img_url": "https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1192198377,2781673332&fm=58&w=150&h=150&img.JPEG"

},

2: {

"url": "http://www.ytmp3.cn/down/52104.mp3",

"songName": "告白气球2",

"singer": "周杰伦1",

"img_url": "https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1192198377,2781673332&fm=58&w=150&h=150&img.JPEG"

}

};


Page({


/**

  * 页面的初始数据

  */

data: {

"songName": "null",

"singer": "singer",

"img_url": "../../images/images/home/everday01.jpg",

"play_butt_icon_url":"../../images/images/stop.png",

"mid":0

},


/**

  * 生命周期函数--监听页面加载

  */

onLoad: function(options) {

if ("mid" in options) {

let mid = options["mid"];

this.togglePlay(mid);

this.refereshElem(mid);

}

music.onPlay(()=>{

console.log("开始播放");

this.setData({

play_butt_icon_url: "../../images/images/play.png"

});

});

music.onPause(() => {

console.log("停止播放");

this.setData({

play_butt_icon_url: "../../images/images/stop.png"

});

});

},

//刷新结构

refereshElem(mid){

let info=data[mid];

this.setData({

singer:info["singer"],

songName:info["songName"],

img_url:info["img_url"],

mid:mid

});

},

//点击play按钮

clickPlayButt: function() {

music.src = data[this.data.mid]["url"];

if (music.paused) {

//paused属性值为true,但是却不执行?

//应该打印true

console.log(music.paused);

music.play();

//应该打印false

console.log(music.paused);

console.log(music)

} else {

music.stop();

}


// this.togglePlay(this.data.mid);

}

//上一曲

,clickPreviousMusic:function(){

this.setData({

mid:1

})

this.togglePlay(this.data.mid);

this.refereshElem(this.data.mid);

}

//下一曲

,clickNextMusic(){

this.setData({

mid:2

});

this.togglePlay(this.data.mid);

this.refereshElem(this.data.mid);

}

,

//定义开关动作

togglePlay: function(mid) {

music.src = data[mid]["url"];

if (music.paused) {

music.play();

} else {

music.stop();

}

}

})



回答关注问题邀请回答
收藏

3 个回答

  • 春风拂槛露华浓
    春风拂槛露华浓
    2019-08-26

    解决了没啊


    2019-08-26
    有用
    回复
  • 2018-12-13

     我也遇到这个问题  真的是奇怪  这bug得消除

    2018-12-13
    有用
    回复
  • 疯狂的小辣椒
    疯狂的小辣椒
    2018-11-26

    麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

    2018-11-26
    有用
    回复
登录 后发表内容