Currently, I'm in the process of creating an html5 video player and have incorporated javascript to update the current time as a fraction of the total time. The script I've written so far is as follows:
function updateTime() {
var curTime = mediaPlayer.currentTime;
var totTime = mediaPlayer.duration;
timePlayed.innerHTML = curTime + '/' + totTime;
}
I've attached an event listener at the beginning to ensure that the script functions correctly. However, the output displays something like 23.703/285.067513
. Is there a way to modify it to show a format similar to 00:00 / 00:00 resembling the YouTube video player? This would entail displaying minutes followed by seconds for both the current time and total duration. In terms of my html code, I only have a span element like this:
<span id="timePlayed">00:00/00:00</span>
. Any assistance with resolving this issue would be greatly appreciated. Thank you!