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


#985

no.............


#986

If there isn't anything else that needs to be in that function, then close the function.


#987

Shouldn't play audio be first?

      function manageAudio(player, opts) {
        if (opts.playing) {
          pauseAudio(player);
        } else {
          playAudio(opts.playing); 
        }

#988

When the audio is already playing, and you click on the button, you want it to play the audio again?

Are you nuts?


#989

I'm confused.


#990

Isn't it already closed?

  function manageAudio(player, opts) {
        if (opts.playing) {
          pauseAudio(player);
        } else {
          playAudio(opts.playing); 
        }

#991

With the manageAudio() function, if the button is currently playing then it pauses the audio.
Otherwise, (because the button isn't currently playing), it plays the audio.

That's how the manageAudio() function works. Surely you can tell how it works from the code that's in the function.


#992

No it's not.


#993

It gets another curly brace?


#994

What do you mean another?


#995

You said it's not closed, that's how you close it.
https://jsfiddle.net/6ts492f6/462/

I don't understand.

How do you close it??

  function manageAudio(player, opts) {
        if (opts.playing) {
          pauseAudio(player);
        } else {
          playAudio(opts.playing); 
        }
}

#996

You close a function by using a closing curly brace.

It looks like you added one for that manageAudio() function, which does the job nicely, although it 's always better to indent the curly brace so that it vertically lines up with the start of the line that has the matching opening brace.


#997

https://jsfiddle.net/6ts492f6/466/

      function manageAudio(player, opts) {
        if (opts.playing) {
          pauseAudio(player);
        } else {
          playAudio(opts.playing);
        });
    }
  }

#998

Do you realise that most (if not all) of what you are adding will eventually need to be removed before the code works?
Most of what you are adding is invalid syntax, and the code won't even attempt to start until it's valid syntax.


#999

https://jsfiddle.net/6ts492f6/466/


#1000

What code do you currently have?


#1001

https://jsfiddle.net/6ts492f6/466/


#1002

The console is complaining about the parenthesis that you added most recently, so remove that.


#1003

SyntaxError: expected expression, got ')'

    function manageAudio(player, opts) {
        if (opts.playing) {
          pauseAudio(player);
        } else {
          playAudio(opts.playing);
        });
    }
  }

#1004

What line number?