Skip to content

Commit

Permalink
feat: add timeUpdate function for audio, change bg-gardient
Browse files Browse the repository at this point in the history
  • Loading branch information
MariyaShusharina committed Sep 22, 2024
1 parent d29ebfd commit 1825d2b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1>Audio Player</h1>
</div>

<div class="audio-div">
<audio src="./assets/songs/Unheilig_-_Schenk_mir_ein_Wunder.mp3"></audio>
<audio src="./assets/songs/Unheilig_-_Schenk_mir_ein_Wunder.mp3" ontimeupdate="timeUpdate()"></audio>
</div>

<div class="controls-div">
Expand Down
18 changes: 18 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ function songTimeChange(value) {
currTimeDiv.textContent = songTime;
}

function timeUpdate() {

songTime = Math.round(audio.currentTime);

timeConverter();

currTimeDiv.textContent = songTime;
}

window.onload = function() {

songMaxTime = Math.round(audio.duration);

maxTimeConverter();

maxTimeDiv.textContent = songMaxTime;
}


/*
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ a:hover { color: #DDDDDD; }
flex-direction: column;
gap: 0.3em;
padding: 1.7em;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.4));
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.3));
border-radius: 1.5em;
}

Expand Down

0 comments on commit 1825d2b

Please sign in to comment.