MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / updateProgressBar

Function updateProgressBar

assets/js/Music_Player.js:94–118  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

92
93// Update Progress Bar & Time
94function updateProgressBar(e) {
95 if (isPlaying) {
96 const { duration, currentTime } = e.srcElement;
97 // Update progress bar width
98 const progressPercent = (currentTime / duration) * 100;
99 progress.style.width = `${progressPercent}%`;
100 // Calculate display for duration
101 const durationMinutes = Math.floor(duration / 60);
102 let durationSeconds = Math.floor(duration % 60);
103 if (durationSeconds < 10) {
104 durationSeconds = `0${durationSeconds}`;
105 }
106 // Delay switching duration Element to avoid NaN
107 if (durationSeconds) {
108 durationEl.textContent = `${durationMinutes}:${durationSeconds}`;
109 }
110 // Calculate display for currentTime
111 const currentMinutes = Math.floor(currentTime / 60);
112 let currentSeconds = Math.floor(currentTime % 60);
113 if (currentSeconds < 10) {
114 currentSeconds = `0${currentSeconds}`;
115 }
116 currentTimeEl.textContent = `${currentMinutes}:${currentSeconds}`;
117 }
118}
119
120// Set Progress Bar
121function setProgressBar(e) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected