audioPlay() {
this.innerAudioContext && this.innerAudioContext.play();
},
audioPause() {
this.innerAudioContext && this.innerAudioContext.pause();
},
audioOnPlay() {
this.videoIsPlay = true;
this.$emit('update:play', true);
},
audioOnPause() {
this.videoIsPlay = false;
this.$emit('update:play', false);
},
audioDestroy() {
this.innerAudioContext && this.innerAudioContext.destroy && this.innerAudioContext.destroy();
this.audioPropInit();
},
audioControls() {
if (this.videoIsPlay) {
this.audioPause();
} else {
this.audioPlay();
}
},
handleBtnClick() {
this.audioControls();
this.$emit('update:play', this.videoIsPlay);
},
contextInit() {
if (this.innerAudioContext) {
this.audioDestroy()
}
let that = this;
if (!that.src) {
if (process.env.NODE_ENV !== 'production') {
console.warn([luch-audio warn]: 'src' 为空
);
}
return;
}
let innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = that.autoplay;
innerAudioContext.loop = that.loop;
if (typeof that.obeyMuteSwitch === 'boolean') {
innerAudioContext.obeyMuteSwitch = that.obeyMuteSwitch;
}
innerAudioContext.onPlay((...arg) => {
console.log('开始播放',e);
that.audioOnPlay();
});
innerAudioContext.onError((e) => {
console.log('播放出错',e);
});
innerAudioContext.src = that.src;
if (that.initAudio) {
that.initAudio(innerAudioContext, { src: that.src, index: that.index });
}
this.innerAudioContext = innerAudioContext;
3 个回复
DCloud_UNI_yuhe
使用插件,去插件市场·@插件作者 来进行提问
9***@qq.com
我和你的问题一样,也是再安卓机,无法播放远程音频,录音的话,是可以播放的;
9***@qq.com
你解决了吗?
1***@qq.com (作者)
可以把远程音频下载到临时文件夹下面,uni.downloadFile这个,然后audio地址填临时文件路径就可以了
2024-08-06 09:23