[英]Make a HTML5 video player play a different file
While a video is playing I can't get the HTML5 player to play a different video, I tried changing the source.src but then it doesn't change the actual video to playing a different file. 在播放视频时,我无法让HTML5播放器播放其他视频,但我尝试更改source.src,但随后并没有将实际视频更改为播放其他文件。 How do I get the video to actually go to the next video?
如何使视频实际转到下一个视频?
This is the part of the code that's not working: 这是不起作用的代码部分:
Javascript: Javascript:
function change(s){
srs=document.getElementById('source');
srs.src="";
srs.src=s;
video.pause();
video.currentTime=0;
video.play();
}
HTML: HTML:
<video id='video'>
<source id='source' src="file:///C:/Users/Ruurd/Music/Far%20East%20Movement%20-%20Turn%20Up%20The%20Love%20ft.%20Cover%20Drive.mp3" >
</video>
PS: This doesn't actually have to work online, i just want to make a video/audio player for myself PS:这实际上不必在线工作,我只想为自己制作一个视频/音频播放器
After you set the src
property, call video.load()
. 设置
src
属性后,调用video.load()
。
Actually, if you're only going to have one single source (presumably, because you know you're going to be using a browser that will play mp3), then you can just simplify and set the src property on the video tag itself. 实际上,如果您只有一个来源(大概是因为您知道将要使用可播放mp3的浏览器),那么您可以简化视频标签本身并设置src属性。
HTML: HTML:
<video id="video" src="file:///C:/Users/Ruurd/Music/Far%20East%20Movement%20-%20Turn%20Up%20The%20Love%20ft.%20Cover%20Drive.mp3"></video>
Javascript: Javascript:
var video = document.getElementById('video');
function change(s){
video.pause();
video.src = s;
video.load();
video.currentTime = 0;
video.play();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.