无法加载,因为找不到支持的源。播放HTML5音频元素时 [英] Failed to load because no supported source was found. when playing HTML5 audio element

查看:2162
本文介绍了无法加载,因为找不到支持的源。播放HTML5音频元素时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有HTML5音频元素

 < audio src =/ sounds / call.wavid =audio1重复=0重复=1class =audio_sound>< / audio> 

如果我尝试调用 element.play()奇怪的错误出现在Chrome Web控制台中。
$ b


未捕获(承诺中)DOMException:加载失败,因为没有
支持的源代码

我还没有找到任何线索为什么会出现这个错误,以及如何解决它。

$ b

解决方案

这可能会也可能不会帮助,但是我遇到了.mp3源文件中的同一个错误消息。我一直在更新内容并且改进了mp3,并没有意识到浏览器已经缓存了mp3文件的原始版本(或者至少它的一部分)。我找不到任何信息来支持它,但有趣的是,似乎音频文件的一部分可能被缓存,并且当浏览器尝试检索文件的其余部分时,它不能(或不)检索完整的工作版本。



我会尝试将您的.wav文件重命名为之前没有使用过的内容,并查看它是否可以使用。


I have HTML5 audio element

<audio src="/sounds/call.wav" id="audio1" repeated="0" repetitions="1" class="audio_sound"></audio>

If I try to call element.play() strange error appears in Chrome web console.

Uncaught (in promise) DOMException: Failed to load because no supported source was found.

I haven't found any clues why this error appears and how to fix it.

解决方案

This may or may not help, but I ran into the same error message on an .mp3 source file. I'd been updating the content and refining the mp3, not realising that the browser had cached the original version of the mp3 file (or part of it, at least). I can't find any info to back this up, but anecdotally it seems that part of the audio file might be cached and when the browser attempts to retrieve the rest of the file, it can't (or doesn't) retrieve a full working version.

I'd try renaming your .wav file to something you haven't used before and see if it starts working.

这篇关于无法加载,因为找不到支持的源。播放HTML5音频元素时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆