Getting audio players to play their respective streams out of their element

showButton(button, {playing}

A link to the code for further investigation would be appreciated.

    function playButton(button) {
      var player = getAudio();
      var playing = isPlaying(button);
      showButton(button, {
          playing
        } manageAudio(player, {
          playing
        });
      }

This is what you did.

     showButton(button, {
          playing
        }; manageAudio(player, {
          playing
        });

The opening parenthesis of the showButton function call, doesn’t have a matching closing parenthesis yet, which needs to go after the first closing curly brace.

Starting manageAudio on a new line will be helpful too.

    function playButton(button) {
      var player = getAudio();
      var playing = isPlaying(button);
      showButton(button, {
          playing
        }
        manageAudio(player, {
          playing
        });

You’ve started manageAudio on a new line, but there’s all of this that you haven’t done yet:

[quote=“Paul_Wilkins, post:1150, topic:282569, full:true”]
The opening parenthesis of the showButton function call, doesn’t have a matching closing parenthesis yet, which needs to go after the first closing curly brace.[/quote]

It’s trying to find a closing parenthesis and is puzzled that after a lot of searching, that it’s finding a closing brace further down instead.

The opening parenthesis of the showButton function call doesn’t have a matching closing parenthesis yet, which needs to go after the first closing curly brace.

matching closing parenthesis

closing curly brace.

All confusing.

Let’s help to clear things up then.

Parenthesis look like this: ( )
Curly braces look like this: { }
Square brackets look like this: [ ]

When you have one parenthesis mark, such as a left, or opening, parenthesis, (
The matching one for that is a right, or closing, parenthesis, ).

Each left must be matched with a matching right one of the same type.

An opening curly brace looks like this: {
And its matching closing one looks like this: }

1 Like
    function playButton(button) {
      var player = getAudio();
      var playing = isPlaying(button);
      showButton(button, {
          playing
        }
        manageAudio(player, {
          playing
        });
           {

It looks like you are making the situation worse.

All you need to do is to close off the call to the showButton() function, in the same way that you are closing off the call to the manageAudio() function.

This

});

in the same way


    function playButton(button) {
      var player = getAudio();
      var playing = isPlaying(button);
      showButton(button, {
          playing
        } });
        manageAudio(player, {
          playing
        });

The closing curly brace ends the object, the closing parenthesis ends the arguments for the function that’s being called, and the semicolon ends the statement.

1 Like

How?

      showButton(button, {
          playing
        }
        
        
        manageAudio(player, {
          playing
        });

How?

The following code calls the sum() function.

var total = sum(1, 2);

The sum refers to the name of the function being called.
The left parenthesis marks the start of the arguments list.
The right parenthesis marks the end of the arguments list.

Together, the left parenthesis and the right parenthesis enclose the arguments being given to the function.
Those arguments in this case happen to be the two values of 1, and 2.
The semicolon indicates that it’s the end of the statement.

1 Like
    function playButton(button) {
      var player = getAudio();
      var playing = isPlaying(button);
      showButton(button, {playing}   
      manageAudio(player, {playing});