我在 HTML 中创建了一个视频播放列表,视频播放,但是当您选择另一个视频时,前一个视频保持突出显示,我希望在单击另一个视频名称后删除突出显示。http://www.evamagnus.com/OurServices.php 在video.js代码中,我有
var position = 0;
var playlist;
var video;
window.onload = function() {
video = document.getElementById('video');
addClickHandlers();
video.src = "video/" + getFormatExtension();
video.load();
video.play();
}
function addClickHandlers() {
var liElements = document.querySelectorAll("ul#videolist li");
for (var i = 0; i < liElements.length; i++) {
var li = liElements[i];
li.onclick = handleVideoSelection;
}
}
function handleVideoSelection(e) {
console.log(e);
var li = e.target;
var src = li.getAttribute("data-src");
var isSelected = li.getAttribute("class");
if (isSelected == "selected") {
if (video.paused) {
video.play();
}
else if (video.ended) {
video.load();
video.play();
}
else {
video.pause();
}
}
else {
li.setAttribute("class", "selected");
video.src = src + getFormatExtension();
video.load();
video.play();
}
}
function getFormatExtension() {
if (video.canPlayType("video/mp4") != "") {
return ".mp4";
} else if (video.canPlayType("video/ogg") != "") {
return ".ogg";
} else if (video.canPlayType("video/webm") != "") {
return ".webm";
}
}
谢谢。