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


#1066

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

      manageAudio(player, {
    playing
      });

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?


#1067

#1068

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


#1069

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


#1070

What am I supposed to do next in the code?


#1071

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.


#1072

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


#1073

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


#1074

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

I read it over and over again.


#1075

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


#1076

player


#1077

Sorry, wrong.


#1078

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

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


#1079

button


#1080

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.


#1081

playing


#1082

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?


#1083

yesssssss


#1084

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.


#1085

I still don't know the answer to this.