当前位置:网站首页>解决使用uni-app MediaError MediaError ErrorCode -5
解决使用uni-app MediaError MediaError ErrorCode -5
2022-07-07 18:42:00 【No Bug】
需要给app做一个语音播报,先在网上找一个在线和成MP3文件网站,合成需要的语音下载好。
放到本地文件里,要使用的时候直接 innerAudioContext.onPlay 就行。
没想到一来就是
在网上找了半天也没有找到解决方式,/(ㄒoㄒ)/~~。
然后我试了试官网的例子,可以正常播放啊。我就把官方例子的播放地址改成自己的本地地址,然后还是老样子!
应该是不能播放本地地址的音频文件,然后我把我的mp3文件存到腾讯云,就可以正常使用了。
改成网络地址后
openVoice() {
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src =
'http://1.14.142.212/zjl.mp3'
innerAudioContext.onPlay(() => {
console.log('开始播放');
});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
});
}
成功播放。哭了/(ㄒoㄒ)/~~
这里稍微讲一下怎么把本地文件放到网络地址上。
思路:
1.需要一个云服务器(购买)。
2.创建FTP站点
3.创建网站站点把文件映射到网络地址
详细步骤
1.我使用的腾讯云,进入宝塔面板创建一个FTP站点

2.进入在你创建FTP的根目录
上传你的文件

3.创建一个网站站点 ,没有域名就用IP,我的域名还是备案中,所以我用的IP。注意根目录和你FTP的一致。

使用
比如我上传了一个mp3文件,访问地址就是
边栏推荐
- 微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
- 阿洛的烦恼
- Network principle (1) - overview of basic principles
- 备份 TiDB 集群到持久卷
- 《数字图像处理原理与实践(MATLAB版)》一书之代码Part2[通俗易懂]
- ISO 26262 - 基于需求测试以外的考虑因素
- ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- Spark judges that DF is empty
- 恶魔奶爸 B1 听力最后壁垒,一鼓作气突破
- 【解决】package ‘xxxx‘ is not in GOROOT
猜你喜欢

OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验

Static analysis of software defects codesonar 5.2 release

Tensorflow2. How to run under x 1 Code of X

写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!

恶魔奶爸 B3 少量泛读,完成两万词汇量+

OneSpin | 解决IC设计中的硬件木马和安全信任问题

I Basic concepts

Apifox 接口一体化管理新神器

【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System

程序猿赚的那点钱算个P啊!
随机推荐
Implement secondary index with Gaussian redis
华为CE交换机下载文件FTP步骤
程序猿赚的那点钱算个P啊!
Mongodb learn from simple to deep
恶魔奶爸 A0 英文零基础的自我提升路
写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
使用高斯Redis实现二级索引
图扑数字孪生煤矿开采系统,打造采煤“硬实力”
TS quick start - Generic
恶魔奶爸 B2 突破语法,完成正统口语练习
Details of C language integer and floating-point data storage in memory (including details of original code, inverse code, complement, size end storage, etc.)
AIRIOT助力城市管廊工程,智慧物联守护城市生命线
Apifox 接口一体化管理新神器
神兵利器——敏感文件发现工具
Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]
How to meet the dual needs of security and confidentiality of medical devices?
Lingyun going to sea | yidiantianxia & Huawei cloud: promoting the globalization of Chinese e-commerce enterprise brands
Alibaba cloud award winning experience: how to mount NAS file system through ECS
Mongodb由浅入深学习
Jenkins 用户权限管理