简体   繁体   English

如何在 html 中播放音频?

[英]How i can play audio in html?

 <audio controls="controls" preload="auto"> <source src="src/audio/blog_audio/music_file.ogg" type="audio/ogg" /> Your browser does not support the audio element. <source src="src/audio/blog_audio/music_file.mp3" type="audio/mp3" /> Your browser does not support the audio element. <source src="src/audio/blog_audio/music_file.aac" type="audio/aac" /> Your browser does not support the audio element. </audio>

I searched a lot here for a solution to the problem of playing the audio in the html5 file not working, and I did not find a solution to my problem, so I want to repeat the question in another form: the audio file works on the device or local host, but after uploading to the server it does not work.我在这里搜索了很多关于在 html5 文件中播放音频的问题的解决方案不起作用,我没有找到解决我的问题的方法,所以我想以另一种形式重复这个问题:音频文件适用于设备或本地主机,但上传到服务器后它不起作用。 I think the code is written correctly and I don't know how to solve it I modified the mp3 audio file type to type="audio/mpeg"我认为代码编写正确,我不知道如何解决我将 mp3 音频文件类型修改为 type="audio/mpeg"

This is the console error这是控制台错误

https://imgur.com/a/GUS48j2 https://imgur.com/a/GUS48j2

Please help to solve the problem请帮忙解决问题

Thank you all谢谢你们

This is not from your code.这不是来自您的代码。 The problem appear because you don't set the correct permissions for the file , this is why you get a 403 error and you can't play audio files on your page.出现问题是因为您没有为文件设置正确的权限,这就是您收到403 错误并且无法在页面上播放音频文件的原因。

(I know my answer is a little bit blur, hope someone else could help you better...) (我知道我的答案有点模糊,希望其他人可以更好地帮助你......)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM