Skip to content

Commit

Permalink
Showing Full Time only on Start
Browse files Browse the repository at this point in the history
  • Loading branch information
SH20RAJ authored Mar 17, 2024
1 parent c3793b4 commit 8e11c6c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions audiplay.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Codepen :- https://codepen.io/SH20RAJ/pen/YzMpONX?editors=0011
// Constants
const ap_playsvg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
Expand Down Expand Up @@ -142,7 +143,7 @@ ap_audioElements.forEach((audioElement, index) => {
downloadButton.style.display = 'none';
}
}
showtime(audioElement, index);
showtime(audioElement, index, true);
});


Expand Down Expand Up @@ -220,15 +221,15 @@ ap_audioElements.forEach((audioElement, index) => {
});

// Function to display audio time
function showtime(audioElement, index) {
function showtime(audioElement, index, start) {
const current = audioElement.currentTime;
const duration = audioElement.duration;
const minutes = Math.floor(current / 60);
const seconds = Math.floor(current - minutes * 60);
const duration_minutes = Math.floor(duration / 60);
const duration_seconds = Math.floor(duration - duration_minutes * 60);
let time = minutes + ":" + (seconds < 10 ? "0" + seconds : seconds) + " / " + duration_minutes + ":" + (duration_seconds < 10 ? "0" + duration_seconds : duration_seconds);

if(start) { time = duration_minutes + ":" + (duration_seconds < 10 ? "0" + duration_seconds : duration_seconds)}
document.querySelector(`.ap_container_${index} .ap_time`).innerHTML = time;
}

Expand Down

0 comments on commit 8e11c6c

Please sign in to comment.