我无法让我的视频正常播放,我将在下面列出我的代码,请问有什么帮助吗?我尝试使用下面输入的代码,但播放视频时出现“ 00:NaN”。这是我下面的HTML。
<html>
<body>
<div id="VideoControls">
<button type="button" id="PlayPause" >Play</button>
<button type="button" id="MuteUnmute" >Mute</button>
<p id="vidTime"></p> <input type="range" id ="seekBar" min=0 max=100 step=1 value=0>
<p>5</p><input type="range" id="volControl" min=0 max=1 step=0.1 value=0.5>
<p id="curtime"></p>
</body>
</html>
这是下面的JavaScript
document.addEventListener('DOMContentLoaded', initialiseWebPage);
function initialiseWebPage()
{
const curtime = document.getElementById ("curtime");
myVideo.addEventListener ("timeupdate",displayVideoTime );
}
function displayVideoTime()
{
let minutes = Math.floor(myVideo.currentTime / 60);
let seconds = Math.floor(myVideo.current % 60);
if(minutes < 10)
{
minutes="0"+minutes;
}
if(seconds<10)
{
seconds="0"+seconds;
}
curtime.innerHTML = minutes+":"+seconds;
}
}
答案 0 :(得分:1)
有一个错字:让秒= Math.floor(myVideo.current%60);必须让秒= Math.floor(myVideo.currentTime%60)