在2 html5视频元素上更改src时获取播放错误

时间:2017-06-20 18:49:31

标签: javascript html5 video

在2 html5视频元素上尝试更改src。当我试图播放这两个视频时,我得到了这个错误:

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

这是代码:

// First the video file is converted to base64 string with PHP and then send it though ajax

$array[$video_id] = 'data:video/mp4;base64,'.base64_encode(file_get_contents(get_template_directory().'/video/'.$video_id.'.mp4'));




var current = // base64 video string

// Current exercises
$('#video_run source').attr('src', current );
video_current = document.getElementById('video_run');
video_current.load();
video_current.play();

var next = // base64 video string

// Next exercises
$('#video_next source').attr('src', next );
video_next = document.getElementById('video_next');
video_next.load();
video_next.play();

base64字符串的例子:

data:video/mp4;base64,[string]

知道我做错了吗?

0 个答案:

没有答案