录音无法播放
发布于 7 年前 作者 cshi 1318 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现

playRecode11: function () {

//const innerAudioContext = wx.createInnerAudioContext();

let that = this;

innerAudioContext.autoplay = true;

innerAudioContext.obeyMuteSwitch = false;

innerAudioContext.onPlay(() => {

console.log(‘开始播放’)

})

innerAudioContext.onError((res) => {

// 播放音频失败的回调

console.log(res)

})

innerAudioContext.onTimeUpdate((res) => {

const currentTime = innerAudioContext.currentTime;

this.setData({

currentTime: this._formatTime(currentTime),

percent: currentTime / this.data.currentSong.duration

})

console.log(currentTime / this.data.currentSong.duration);

if (this.data.currentLyric) {

this.handleLyric(currentTime * 1000)

}

})

innerAudioContext.onEnded((res) => {

console.log(“innerAudioContext播放完成”);

this.setData({

b_img: “…/…/images/c_musice/bf.png”,

b_type: “1”,

currentTime: this.data.duration,

percent: 1

})

console.log(“innerAudioContext currentTime” + that.data.percent)

})

innerAudioContext.src = this.data.recodePath; // 这里可以是录音的临时路径

console.log(“录音路径:” + this.data.recodePath)

//innerAudioContext.play();

if (that.data.b_type == “1”) {

innerAudioContext.play()

that.setData({

b_img: “…/…/images/c_musice/zt.png”,

b_type: “2”

})

} else {

innerAudioContext.pause()

that.setData({

b_img: “…/…/images/c_musice/bf.png”,

b_type: “1”

})

}

},

  • 复现路径
  • 提供一个最简复现 Demo
2 回复

你好,打印失败的回调没有信息提示的吗?

都正常,就是不出声音,

innerAudioContext.onTimeUpdate((res) => {

const currentTime = innerAudioContext.currentTime;

this.setData({

currentTime: this._formatTime(currentTime),

percent: currentTime / this.data.currentSong.duration

})

console.log(currentTime / this.data.currentSong.duration);

if (this.data.currentLyric) {

this.handleLyric(currentTime * 1000)

}

})

这个都能打印出时间

回到顶部