我有HTML5音频元素
<audio src="/sounds/call.wav" id="audio1" repeated="0" repetitions="1" class="audio_sound"></audio>
Run Code Online (Sandbox Code Playgroud)
如果我尝试element.play()在Chrome网络控制台中显示奇怪的错误.
未捕获(在promise中)DOMException:无法加载,因为找不到支持的源.
我没有找到任何线索,为什么会出现此错误以及如何解决它.
我收到DOMException:无法加载,因为在video.play()中找不到支持的源 ; 线.我只是在添加了video.setAttribute('crossorigin','anonymous')之后才遇到这个问题; 我正在开发移动应用程序,所以对于交叉起源我需要添加这一行.更新chrome 50版本后,我在此之前遇到此问题,它可以正常工作.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
<script>
var video = document.createElement( 'video' );
video.id = 'video';
video.type = ' video/mp4; codecs="theora, vorbis" ';
video.src = "http://abcde.com/img/videos/what_is_design_thinking.mp4";
video.volume = .1;
video.setAttribute('crossorigin', 'anonymous');
video.load(); // must call after setting/changing source
$('body').html(video);
video.play();
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
$('body').append(canvas);
video.addEventListener('play', function() {
var $this = this; //cache
(function loop() {
if (!$this.paused && !$this.ended) {
ctx.drawImage($this, 0, 0);
setTimeout(loop, 1000 …Run Code Online (Sandbox Code Playgroud)