小程序
小游戏
企业微信
微信支付
扫描小程序码分享
InnerAudioContext播放音频,在真机上报{errCode: 10001, errMsg: "errCode:62, err:load or init native decode so fail"},而且经常会有seek()失效的问题,怎么解决
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
<slider bindchange="sliderChange" bindchanging="sliderChanging" block-size="12px" value="{{value}}" max="{{duration}}" activeColor="#FA643C" />
play: function() {
if (this.data.isplay) {
this.data.iac.pause();
} else {
this.data.iac.src = this.data.audiosrc;
this.data.iac.play();
}
sliderChanging: function(e) {
let that = this;
if (!that.data.isdrag) {
let drplay = that.data.isplay;
that.setData({
isdrag: true,
drplay: drplay
});
if (drplay) {
that.data.iac.pause();
// 进度条拖拽
sliderChange: function(e) {
console.log('sliderChange');
let value = parseInt(e.detail.value);
let iac = that.data.iac;
isdrag: false
iac.seek(value);
if (that.data.drplay) {
iac.play();
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
<slider bindchange="sliderChange" bindchanging="sliderChanging" block-size="12px" value="{{value}}" max="{{duration}}" activeColor="#FA643C" />
play: function() {
if (this.data.isplay) {
this.data.iac.pause();
} else {
this.data.iac.src = this.data.audiosrc;
this.data.iac.play();
}
}
sliderChanging: function(e) {
let that = this;
if (!that.data.isdrag) {
let drplay = that.data.isplay;
that.setData({
isdrag: true,
drplay: drplay
});
if (drplay) {
that.data.iac.pause();
}
}
}
// 进度条拖拽
sliderChange: function(e) {
console.log('sliderChange');
let that = this;
let value = parseInt(e.detail.value);
let iac = that.data.iac;
that.setData({
isdrag: false
});
iac.seek(value);
if (that.data.drplay) {
iac.play();
}
}
let that = this;
// 创建音频上下文
let iac = wx.createInnerAudioContext();
iac = wx.createInnerAudioContext();
iac.src = that.data.audiosrc;
// 监听音频播放事件
iac.onPlay(() => {
console.log('onPlay');
that.setData({
isplay: true
});
});
// 监听音频播放进度更新事件
iac.onTimeUpdate(function() {
if (that.data.isdrag) {
return;
}
let duration = iac.duration;
let value = iac.currentTime;
that.setData({
max: duration,
value: value
});
});
iac.onWaiting(function() {
console.log('onWaiting');
that.setData({
isloading: true
});
});
iac.onCanplay(function() {
console.log('onCanplay')
that.setData({
isloading: false
});
});
// 监听音频暂停事件
iac.onPause(function() {
console.log('onPause');
that.setData({
isplay: false
});
});
// 监听音频停止事件
iac.onStop(function() {
console.log('onStop');
that.setData({
isplay: false
});
iac.seek(0);
});
// 监听音频自然播放至结束的事件
iac.onEnded(function() {
console.log('onEnded');
that.setData({
isplay: false
});
iac.seek(0);
});
// 监听音频播放错误事件
iac.onError(err => {
console.log('监听音频播放错误事件', err, iac.src);
that.setData({
isplay: false,
isloading: false
});
util.progressTips('音频播放失败!');
});
that.setData({
iac: iac
});
}