dcloudio / dcloudio/uni-app

使用uni.createInnerAudioContext()播放base64音频无法正常播放

Open
#4,752 1 comment 2 reactions 1 assignee Claimed by @GRCmade View on GitHub
Android uni api
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
使用uni.createInnerAudioContext()
在src中设置base64,如:data:audio/mp3;base64, *
提示MediaError,-99
是createInnerAudioContext无法播放base64吗?但是在audio组织中用base64可以正常播放;

**复现步骤**
[复现问题的步骤]

[或者可以直接贴源代码]
`speak(text) {
store.dispatch("GET_TTS_WS_BASE64", text).then(base64=>{
if(this.innerAudioContext){
this.innerAudioContext.stop()
this.innerAudioContext = null
}
this.innerAudioContext = uni.createInnerAudioContext()
this.innerAudioContext.src = base64
const that = this
this.innerAudioContext.onCanplay(()=>{
console.log('onCanplay');
that.innerAudioContext.play()
that.innerAudioContext.onEnded(()=>{
console.log('onEnded');
})
})
this.innerAudioContext.onError((res) => {
console.log('onError',res.errMsg);
console.log('onError2',res.errCode);
})
})
}`
**预期结果**
Android手机正常播放音频;

**实际结果**
[这里请贴上你的报错截图或文字]
innerAudioContext.onError中报错:MediaError,-99

**系统信息:**
- 发行平台: 5+ App
- 操作系统 [Android 10.0]
- HBuilderX版本 [ HBuilderX 版本号3.99]
- uni-app版本 [2]
- 设备信息 [霍尼韦尔EDA51K]

**补充信息**
[可选]
是不是对base64长度有要求?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.