downloadAudio(src) { let that = this that.isDownloadProgressPopup = true const downloadTask = wx.downloadFile({ url: src, // http得网络mp3音频地址 success: res => { if (res.statusCode === 200) { that.isDownloadProgressPopup = false // 关闭下载进度弹窗 let tempAudioPath = res.tempFilePath let mediaContainer = wx.createMediaContainer() mediaContainer.extractDataSource({ source: tempAudioPath, success: recording => { mediaContainer.addTrack(recording.tracks[0]) recording.tracks[0].volume = 1 // 调整音频的音量 mediaContainer.export({ success: res => { that.videoSrc = res.tempFilePath mediaContainer.removeTrack(recording.tracks[0]) that.savePictures() // 调用保存相册 } }) }, fail: err => { wx.showToast({ title: `${err}解析视频失败`, icon: 'none', duration: 1000 }) } }) } }, fail: err => { that.isDownloadProgressPopup = false // 关闭下载进度弹窗 wx.showToast({ title: `${err}下载失败`, icon: 'none', duration: 1000 }) } }) downloadTask.onProgressUpdate((res) => { that.progress = `${res.progress}%` }) },
wx.createMediaContainer()提取一个MP3格式得音频,导出后保存没有声音?wx.createMediaContainer()提取一个MP3格式得音频,导出后保存到本地相册,再安卓机内有声音,再iphone一些设备上有视频源,但是没有声音,也没有播放
2023-11-01