View Single Post
Old 02-14-2013, 08:52 AM   PM User | #7
Entity_
New Coder

 
Join Date: Dec 2012
Location: Ingerlund
Posts: 63
Thanks: 8
Thanked 4 Times in 4 Posts
Entity_ is an unknown quantity at this point
Code:
    var birdSound = document.getElementById("player");
    var coverBirds = document.getElementById("coverBirds");
    var trigger = 5;
    
    

    birdSound.addEventListener(
       'timeupdate',
       function () {
           console.log(this.currentTime);
           if (coverBirds.paused) {
               if (this.currentTime > trigger) {
                   console.log("eventalert");
                   coverBirds.play(); 
               }
           }
       }
   );
Sorry for not making it clearer before. I quickly typed in the birdSound.play line you found because I had I hadn't actually got round to calling the new sound first. I wanted to first make sure it was working, and it still isn't. Here's where I'm at now. This whole code works fine if you change the conditional

Code:
 if (this.currentTime > trigger)
to

Code:
 if (this.currentTime < trigger)

But if I keep it as > it just does nothing. While you are indeed astute for noticing the birdSound problem, that's something I typed in while writing the forum post just to make it clearer, but I accidentally typed the wrong variable and got the syntax wrong, so it's not the main problem with the code. I'm sure the issue is somewhere with the > as it works if you tell it to go <, and I've commented out successive lines until only this line remained.
Entity_ is offline   Reply With Quote