当前位置:网站首页>解决使用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文件,访问地址就是
边栏推荐
猜你喜欢

How does codesonar help UAVs find software defects?

如何满足医疗设备对安全性和保密性的双重需求?

写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
CodeSonar通过创新型静态分析增强软件可靠性

Airiot helps the urban pipe gallery project, and smart IOT guards the lifeline of the city

Mongodb learn from simple to deep

大厂经典指针笔试题

Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation

ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your

OneSpin 360 DV新版发布,刷新FPGA形式化验证功能体验
随机推荐
深度学习模型压缩与加速技术(七):混合方式
Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry
guava多线程,futurecallback线程调用不平均
[concept of network principle]
Prometheus remote_write InfluxDB,unable to parse authentication credentials,authorization failed
EasyGBS级联时,上级平台重启导致推流失败、画面卡住该如何解决?
CodeSonar如何帮助无人机查找软件缺陷?
How to choose fund products? What fund is suitable to buy in July 2022?
Tensorflow2.x下如何运行1.x的代码
Onespin | solve the problems of hardware Trojan horse and security trust in IC Design
2022如何评估与选择低代码开发平台?
[MySQL - Basic] transactions
Network principle (1) - overview of basic principles
AIRIOT助力城市管廊工程,智慧物联守护城市生命线
4G设备接入EasyGBS平台出现流量消耗异常,是什么原因?
【奖励公示】第22期 2022年6月奖励名单公示:社区明星评选 | 新人奖 | 博客同步 | 推荐奖
想杀死某个端口进程,但在服务列表中却找不到,可以之间通过命令行找到这个进程并杀死该进程,减少重启电脑和找到问题根源。
CodeSonar网络研讨会
恶魔奶爸 A0 英文零基础的自我提升路
恶魔奶爸 C