Skip to content

Instantly share code, notes, and snippets.

@wwj718
Created March 13, 2019 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwj718/c073bc145bcac8e812e5c168ecedabf7 to your computer and use it in GitHub Desktop.
Save wwj718/c073bc145bcac8e812e5c168ecedabf7 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>video player</title>
</head>
<body onload="onload();">
<video
id="idle_video"
onended="onVideoEnded();"
controls="controls"
></video>
<script>
// 输入视频名称
var video_list = ["wormhole.mp4", "blender.mp4", "cozmo_vector.mp4"];
var video_index = 0;
var video_player = null;
function onload() {
console.log("body loaded");
video_player = document.getElementById("idle_video");
video_player.setAttribute("src", video_list[video_index]);
video_player.play();
}
function onVideoEnded() {
console.log("video ended");
if (video_index < video_list.length - 1) {
video_index++;
} else {
video_index = 0;
}
video_player.setAttribute("src", video_list[video_index]);
video_player.play();
}
</script>
</body>
</html>
@wwj718
Copy link
Author

wwj718 commented Mar 13, 2019

循环播放当前文件夹内多个视频: video_list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment