Setting a breakpoint on that line and running the code, I see that player equals
Why is that? The call stack shows me that the playAudio() function is called by the manageAudio() function. Let's take a look there and find out what's going on.
Well there's your problem. The manageAudio() function is calling playAudio() with a boolean as its first argument, when the playAudio() function expects a player as the first argument when calling it instead.