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


This is the code in the playButton() function that calls the manageAudio() function.

      manageAudio(player, {

The first argument given to manageAudio is player
The second argument given to manageAudio is an object, that contains playing

Are you getting that so far?

When the manageAudio() function runs, it receives the first argument as its first parameter.

    function manageAudio(player, opts) {

The first parameter of the manageAudio() function is player, so that first argument is received as player.
The second parameter if the manageAudio() function is opts, so that second argument is received as opts.

From that, can you understand that code in the playButton() function gives an object as the second argument, which is received by the second function parameter as opts?



I don't understand what I'm supposed to do?


You are supposed to let me know any of what I said is unclear to you.


What am I supposed to do next in the code?


Nothing yet, until you understand what needs to be done. That will be achieved by reading what I wrote in post #1066, and filling in any gaps of understanding that may exist.


I read what you wrote, what are the next steps.


Is there anything in what I wrote that you want further clarification on?



I read it over and over again.


Good, then you'll be able to answer where the manageAudio() function gets opts from.




Sorry, wrong.


The manageAudio() function has opts as its second parameter.

What is it that gives arguments to the manageAudio() function?




No, not that either.

It seems that you don't understand, and I'm going to be forced to do this even more slowly to help you out.




When you call a function, you supply arguments that are to be given to that function that you are calling.

For example:

var total = sum(1, 2);

The sum function is called, and is given two arguments. The first argument is the number 1, and the second argument is the number 2.

Are we on the same page here yet? Is this making sense to you?




Those arguments are then received by the function as function parameters.

For example:

function sum(x, y) {
  // implementation details not required

The sum() function has x as its first parameter, and it has y as its second parameter.

With a call to sum(1, 2), the first argument of the number 1 is received by the sum() function as a parameter of x, and the second argument of the number 2 is received by the sum() function as a parameter of y

Does this help to demonstrate the difference between parameters and arguments?

Arguments are given when calling a function,
Parameters are always defined as a part of a function declaration.
When calling a function, the arguments that are given end up being received by the function as parameters instead.


I still don't know the answer to this.