What do I do next?
function playButton(button) {
var player = getAudio();
var playing = isPlaying(button);
showButton(button, playing);
manageAudio(opts.playing, {
playing
});
}
What do I do next?
function playButton(button) {
var player = getAudio();
var playing = isPlaying(button);
showButton(button, playing);
manageAudio(opts.playing, {
playing
});
}
That function is trying to use opts
, but it currently doesnât exist as a function parameter.
Why isnât the audio playing?
opts
is broken - fix it.
How?
ReferenceError: opts is not defined
The playButton() function shouldnât need to know about opts. Remove it.
What is the first parameter of the manageAudio() function?
Remove what??
manageAudio(opts.playing, {
});
}
to:
manageAudio(playing, {
});
}
one thing at a time.
Those are the arguments that you are passing to the manageAudio() function. They arenât the parameters that the manageAudio() function accepts.
Now please find and identify what is the first parameter of the manageAudio() function.
You just told me to do this:
I didnât do this yet.
The playButton() function shouldnât need to know about opts. Remove it.
In order to fix the problem that you currently have there, you need to first understand what you must give as the first argument to the manageAudio() function.
Let me know when you want to understand that.
playing.
And thatâs the only thing that should be in there.
Wrong. playing
is not the first parameter that is accepted by the manageAudio() function.
function manageAudio(player, opts) {
if (opts.playing) {
pauseAudio(player);
} else {
playAudio(opts.playing);
}
}
As you can see there, it is not playing
that is accepted as the first parameter, but is player
instead.
playing
is a boolean value that can be a value of either true
or false
which indicates whether the button is currently playing or not.
player
is a reference to the HTML audio player element.
Both are very different things.
Still no audio:
You are still using opts
in the playButton() function when you shouldnât be.
What now?
Should I not be using opts in any of these either?
function manageAudio(player, opts) {
if (opts.playing) {
pauseAudio(player);
} else {
playAudio(opts.playing);
}
}