Well, see, my *GUESS* was that for some reason when you got the reference to the playing sound via
Code:
var birdSound = document.getElementById("player");
that for some reason that was getting the state of the player *AT THE TIME* of that assignment. (Don't ask me why! Shouldn't be true, but...)
So since my code above seemed to work, it seems to me the answer is to just move that assignment inside the function:
But... but with this new code, I don't see any reason to refer to that variable, anyway.
What about
:
Code:
birdSound.addEventListener(
'timeupdate',
function () {
console.log(this.currentTime);
if (coverBirds.paused)
{
if (this.currentTime > trigger )
{
alert("eventalert");
birdSound.play; // **** IS THIS RIGHT ??? ****
}
}
}
);
But in that code, shouldn't
birdSound.play really be
coverBirds.play ?
And are you sure it should be
.play? You used that property, above, to indicate that the element *is* playing (or not). Here you seem to be wanting to invoke a *method* that tells it to start playing?
I just checked the docs. I'm right. To start something playing you use
.play( ) -- call the method. Using just
.play doesn't tell you anything except whether the object in question *has* a play method! So you were using it wrong all along.
So I *think* the line in question should be
coverBirds.play( )
Assuming I understand your intent.