微信html播放音频m4a,IOS音频播放只支持m4a格式,mp3格式播放不了

51b7153c3e20498da436f456f0e2d8fc.pngJoker

2020-01-20

加粗

标红

插入代码

插入链接

插入图片

上传视频

请 登录 后发表内容

关闭

新增或编辑超链接

链接地址

关闭

插入视频

视频链接

苹果七,苹果X;7.0.10;12.4.1, 13.3.0;

wx.setInnerAudioOption({

obeyMuteSwitch: false

})

var innerAudioContext = null;

Page({

/**

* 页面的初始数据

*/

data: {

formatedPlayTime: '00:00',

playStatus: true, //未播放的图片

imgDesc: {  }

},

// 音频播放

musicStart: function(e) {

let that = this

this.setData({ playStatus: false })

innerAudioContext.src = this.getSrc(that);

console.log(this.getSrc(that))

innerAudioContext.play();

this.updateTime(that);

},

getSrc: function(that) {

return that.data.imgDesc.src

},

updateTime: function(that) {

innerAudioContext.onTimeUpdate((res) => {

that.setData({

formatedPlayTime: that.formatTime(innerAudioContext.currentTime)

})

})

if (innerAudioContext.duration.toFixed(2) - innerAudioContext.currentTime.toFixed(2) <= 0) {

that.setStopState(that)

}

innerAudioContext.onEnded(() => {

that.setStopState(that)

})

},

canel_handover() {

// innerAudioContext.offPause(); //取消录音暂停

innerAudioContext.pause(); //语音暂停

this.setData({

playStatus: true

})

},

setStopState: function(that) {

that.setData({

formatedPlayTime: "00:00",

playStatus: true, //图片展示为未播放

})

innerAudioContext.stop(); //

},

formatTime: (time) => {

time = Math.floor(time);

var m = Math.floor(time / 60).toString();

m = m.length < 2 ? '0' + m : m;

var s = (time - parseInt(m) * 60).toString();

s = s.length < 2 ? '0' + s : s;

return m + ':' + s;

},

/**

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

*/

onLoad: function(options) {

let that = this

innerAudioContext = wx.createInnerAudioContext();

innerAudioContext.onError((res) => {

console.log(res.errMsg);

console.log(res.errCode);

});

},

/**

* 生命周期函数--监听页面隐藏

*/

onHide: function() {

let that = this;

this.setStopState(that)

innerAudioContext.destroy()

},

/**

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

*/

onUnload: function() {

let that = this;

this.setStopState(that)

innerAudioContext.destroy()

},

})

你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。待楼主反馈

2020-01-20

回复

关闭

请选择投诉理由

广告内容

违法违规

恶意灌水内容

其他

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值