当前位置:网站首页>Solve the problem of using uni app mediaerror mediaerror errorcode -5

Solve the problem of using uni app mediaerror mediaerror errorcode -5

2022-07-07 21:06:00 No Bug

Need to give app Make a voice broadcast , First find an online Hecheng MP3 File website , The voice needed for synthesis is downloaded well .

Put it in the local file , To use it directly innerAudioContext.onPlay Just go .

I didn't expect it to be

After searching online for a long time, I couldn't find a solution ,/(ㄒoㄒ)/~~.

Then I tried the example of the official website , It can be played normally . I will change the broadcast address of the official example to my local address , Then it's the same !

It should not be able to play audio files with local addresses , Then I put my mp3 Save the file to Tencent cloud , It can be used normally .

Change to network address

            openVoice() {
                const innerAudioContext = uni.createInnerAudioContext();
                innerAudioContext.autoplay = true;
                innerAudioContext.src =
                    'http://1.14.142.212/zjl.mp3'  
                innerAudioContext.onPlay(() => {
                    console.log(' Start playing ');
                });
                innerAudioContext.onError((res) => {
                    console.log(res.errMsg);
                    console.log(res.errCode);
                });
            }

Played successfully . crying /(ㄒoㄒ)/~~

Here is a little talk about how to put local files on the network address .

Ideas :

1. You need a cloud server ( Buy ).

2. establish FTP Site

3. Create a website, map the file to the network address

The detailed steps

1. I use Tencent cloud , Enter the pagoda panel to create a FTP Site

2. Enter when you create FTP Root directory

Upload your file

3. Create a web site  , Use it without a domain name IP, My domain name is still on record , So I used IP. Pay attention to the root directory and you FTP The consistency of .

Use

For example, I uploaded a mp3 file , The access address is

http://1.14.142.212/zjl.mp3

 

原网站

版权声明
本文为[No Bug]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071842366392.html