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


#799

The closing right brace at the end of the code that you pasted is the end of the if/else block of code.

It is below that closing right brace where the button/hide/link lines need to go.


#800

function togglePlayButton(button) {
     var link = upTo(button, ".links");
     var player = button.querySelector("audio");
     var play = button.querySelector(".play");
     var pause = button.querySelector(".pause");
  player.volume = 1.0;


    if (player.paused) {

     } else {

       hide(play);
       show(pause);
       player.play();

     button.classList.add("playing");
     hide(button.querySelector(".initial"));
     link.classList.remove("inactive");
   
 
       show(play);
       hide(pause);
       player.pause();
     }

#801

Are you understanding anything about identifying the end of the if/else block of code?


#802

You told me it was Good.

#773


#803

It was good when I replied. After my reply it seems that you edited the post.

What you now have there in post #773 is an abomination that can never work.

I'm going out for a walk, will be back later.


#804

if (player.paused) {

     } else {

       hide(play);
       show(pause);
       player.play();

#805

   function togglePlayButton(button) {
     var link = upTo(button, ".links");
     var player = button.querySelector("audio");
     var play = button.querySelector(".play");
     var pause = button.querySelector(".pause");
     player.volume = 1.0;
     if (player.paused) {} else {
       button.classList.add("playing");
       hide(button.querySelector(".initial"));
       link.classList.remove("inactive");
       show(play);
       hide(pause);
       player.pause();
     }
     hide(play);
     show(pause);
     player.play();
   }

#806

This one uses both triggered and isPlaying
https://jsfiddle.net/fsesrh2b/4/

 button.classList.add("triggered");

 if (isPlaying()) {

Should I change them to?

active

and

isActive


#807

Okay, I'm back. Let's get the code at https://jsfiddle.net/aebwrk6p/16/ updated so that you can easily have the player default to not playing when you first click on it.

Because you have been demonstrating a severe lack of understanding with some of the standard terminology that I've been using, I need to clear up some potential misunderstandings first.

With that version 16 code, can you please find and tell me the line numbers for the start of the if statement, and the end of the if statement.


#808

player.volume = 1.0;

you said should be above if.


#809

Yes that's right. And for the rest of it, I need to know that you can identify the correct line numbers for the start and the end of the if statement.


#810

https://jsfiddle.net/aebwrk6p/23/

29

30

31


#811

28

29

30


#812

Okay, that information is incorrect. There are only two line numbers that are being asked about.

One of them is for the line number at the start of the if statement, and the other is for the line number of the end of the if statement.


#813

The line number for the start of the if statement will be the easier of the two to figure out.


#814

27

31


#815

No, 27 is the player.volume line, that is not the start of the if statement.
Line 31 is not the line number for the end of the if statement. Instead, that is the line number of the last statement in the if statement.

Knowing that, can you please identify the start and end line numbers for the if statement.


#816

https://jsfiddle.net/aebwrk6p/26/


#817

The code is not being asked for.

It is the line numbers from your most recent code of https://jsfiddle.net/aebwrk6p/23/ of the start and end lines of the if statement, are what are being asked for.


#818
27

https://jsfiddle.net/aebwrk6p/26/
31