我正在Squarespace网站上工作,他们不允许视频上传,因此我使用Dropbox来托管视频。从Dropbox使用HTML5视频播放器的MP4,不重复
视频开始播放,但他没有重复。
这是代码:
<video id="htmlVideo" loop="loop">
<source type="video/mp4" src="https://www.dropbox.com/s/videoID/videoplayback.mp4?dl=1">
</video>
可能是什么问题呢?
这是我如何创建视频
/*
function repeatForDropbox() {
console.log("repeatForDropbox caled" + htmlVideo);
}
*/
function createVideo() {
var video = document.createElement("video");
video.id = "htmlVideo";
video.loop = "loop";
var vidSource = document.createElement("source");
vidSource.type = "video/mp4";
vidSource.src = "https://www.dropbox.com/s/videoID/videoplayback.mp4?dl=1";
video.appendChild(vidSource);
var vidLocation = document.querySelector('#location').parentNode;
vidLocation.appendChild(video);
htmlVideo = document.querySelector(" #htmlVideo ");
// on load, play the video/mp4
window.onload = function() {
setTimeout(function() {
htmlVideo.play();
// htmlVideo.addEventListener("ended", repeatForDropbox);
// I tried here to make the video repeat, using the "ended" event listener
// so when the video ended, the video
// should get another <source> element(same src)
// and delete the old one
// but the event didn't fire
// I also tried htmlVideo.onended = function() {} , but same result
}, 500);
}
}
您试图更改'loop =“loop”'为:'
@Ferrrmolina,我怎么用Javascript做到这一点?只添加“循环”。 – Marian07
在html标记中。 – Ferrrmolina