Two versions of a playButton Binding Audio With a grid link structure


#882

Does the code work?


#883

ReferenceError: isPlaying is not defined
[Learn More]


#884

You failed to follow these instructions.

Do that.


#885

  var pause = button.querySelector(".pause");
     player.volume = 1.0;
     if (isActive() && isPlaying()) {

#886

You have isPlaying() there which is wrong. Fix it.


#887

https://jsfiddle.net/aebwrk6p/42/


#888

Good, the play button still works.

We can now replace that return true statement, with code that checks if the button is active, which is:

return button.classList.contains("active");

That won't work though until you give isActive the button, so change isActive() to isActive(button) and all is good.


#889

   var pause = button.querySelector(".pause");
     player.volume = 1.0;
     if  (isActive(button)() && player.paused) {

#890

It looks like a mistake occurred when you attempted to follow one of those instructions.


#891

What was the mistake?


#892

Here's what I said:


#893

   function isActive(button) {
   return button.classList.contains("active");
   
   }

https://jsfiddle.net/aebwrk6p/46/


#894

You still haven't changed isActive() to isActive(button) so do that.


#895

Which one?

[ function isActive(button) {

if (isActive() && player.paused) {


#896

https://jsfiddle.net/aebwrk6p/47/


#897

What you show there is the function declaration which shows that it receives one parameter called button.
That is not what I'm talking about.

I am talking about the if statement that currently has isActive()

That calls the isActive function with no arguments. You need to call the isActive function with an argument of button.


#898

Good, that looks like it works as desired now.


#899

#859

#806

Change playing/triggered to active, or leave as is?

    function isPlaying() {
        return player.paused === false;
    }
    function toggle() {
        if (isPlaying())

button.classList.add("triggered");

#900

Are you wanting to work on the other code there now?


#901

Please edit your post before hitting Reply.

When you go back to edit it afterwards, no notifications are sent out about the changes that you made after doing the reply.


Exposure from the depths of large topics