View Single Post
Old 02-13-2013, 11:42 PM   PM User | #5
Entity_
New Coder

 
Join Date: Dec 2012
Location: Ingerlund
Posts: 62
Thanks: 8
Thanked 4 Times in 4 Posts
Entity_ is an unknown quantity at this point
Ok so now I know my audio is playing, thankyou very much. But my original post eluded to another problem, for which I created that code snippet. If you'd be so kind and if you have the time maybe you could help me, because the result of actually knowing that the file is playing is even more confusing.

Code:
    
    var birdSound = document.getElementById("player");
    var coverBirds = document.getElementById("coverBirds");
    var trigger = 2;
    
    

    birdSound.addEventListener('timeupdate', function () {
            console.log(birdSound.currentTime);
            if (coverBirds.paused) {
            if (birdSound.currentTime > trigger ) {
                alert("eventalert");
                birdSound.play
           }
     }
});
There is the code. It basically plays one audio element (coverBirds) at a specific time in another audio element (birdSound). It does this by checking if coverBirds is not playing, if it's not playing it checks to see if the time of birdSound has passed the allowed thresh hold set by the trigger variable. It's set up in this way so the timeupdate will not spam the sound file upon the condition being met. The problem is somewhere is the event listener i think. I think this because I added the console.log line to see if it was firing properly and instead it fired twice and that's it. Is there something I'm doing wrong?

P.S Thanks in advance for your time, if you decide to help
Entity_ is offline   Reply With Quote