我正在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