function showSpeakerHandler() {
if (isActive() && isPlaying()) {
images.showIcon("speaker");
}
}
function showSpeakerHandler() {
if (isPlaying()) {
images.showIcon("speaker");
}
}
function showSpeakerHandler() {
if (isActive() && isPlaying()) {
images.showIcon("speaker");
}
}
function showSpeakerHandler() {
if (isPlaying()) {
images.showIcon("speaker");
}
}
You are screwing things up again.
Go back to the code in https://jsfiddle.net/cubphcqd/58/
It is the condition of the if statement in that code that needs to be updated.
We were working on the code at https://jsfiddle.net/cubphcqd/58/ and should continue working on that code until it is working as desired.
I will not be working on other code until this current tiny feature that you require on https://jsfiddle.net/cubphcqd/58/ has been achieved.
(isActive() && isPlaying())
Was in reference to what?
That is whatâs required for the code at https://jsfiddle.net/cubphcqd/58/ to not play when you first click on it.
I thought we werenât using isPlaying?
Yes we are.
The isPlaying() function is how the code tells if the audio player is playing. Thatâs how it knows whether to show the play or pause button.
When the player shows the fancy image and it isnât showing the play or pause button, itâs not active.
When the image is gone and the play or pause button is being shown, the player is active.
Currently though the if condition at https://jsfiddle.net/cubphcqd/58/ uses player.paused
so we donât need to be concerned with isPlaying yet.
Currently when the button isnât active, you donât want it to start playing. Is that right?
When itâs first viewed, audio off.
You have to click on it to turn it on.
Thatâs right. So only when itâs active (which the code after the if statement achieves) and when the audio is paused, will it start playing.
To achieve that, the condition of the if statement needs to be updated.
Currently the condition is (player.paused) which needs to be updated to (isActive() && player.paused)
You are missing the isActive function.
Weâll keep it nice and simple first, while we get the code working.
Then we will change isActive so that is looks for the right thing.
Create the isActive function above the togglePlayButton function, in the same way that you did so before.
You moved button back up:
button.classList.add("playing");
hide(button.querySelector(".initial"));
link.classList.remove("inactive");
I didnât move it.
That needs to be down below the end if the if/else block of code.
Inside of that isActive function, return true.
That will do temporarily while we check that the code still works. When itâs confirmed as working, progress can continue from there.
function isActive(button) {
return true;
}