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

15
Feb

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

如果在Chrome 50+ 通过js控制Html5 video/audio 元素的play(),可能会弹出下列问题

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

会在promise中触发原因是Chrome的一次更新

一开始我在使用DPlayer by Diygod引用部署在阿里云oss上的视频时报的错,看了stackoverflow上的一些答案都不能解决,然后发现原来是一句crossOrigin = "Anonymous"的问题

<video src="someoss.com/xx.mp4" crossOrigin = "Anonymous"></video>

去掉后就可以了,我想原因是阿里云oss的来源监控不允许匿名访问,虽然我设置是公共读并且没有refer限制。

添加新评论