1

On a .js page in a Visual Studio express ASP.NET solution why does

window.onload() {
document.getElementById('ambience').play(); 
}

work(and it does!), but why does

window.onload() {
document.getElementById('ambience').play(); 
document.getElementById('ambience').stop(); 
}

NOT stop the music? .pause(); doesn't pause the music either I also tried:

It does play the music. And I have tried:

window.onload =  function() {

    var snd = document.getElementById('ambience').play();
    var clickmeButton = document.getElementById('playJackpot');
    clickmeButton.onclick = playSound;
}

function playSound() {
    document.getElementById('ambience').stop();
}

what is the equivalent of .stop() or .pause() if those are not applicable? what set of commands should I be working with in visual studio in order to get sound to play based on a conditional and then definitively shut off or stop after it has played once, and only once ? The background to this is that I have the play button in a timer control, so that it can operate other features, but each timer tick (and that needs to be set at a fraction of a second) kicks off the play again, so that the sound comes out staccato, because it is starting with every 'tick' of the timer. So, I need to play it, then immediately shut off the sound's ability to play, that is until somebody hits the play button again.

  • 5
    you're telling it to play and stop milliseconds apart from each other, it probably can't stop because it hasn't started yet. – DLeh Jan 15 '15 at 20:51
  • in addition, `stop()` doesn't seem to be a valid method http://www.w3schools.com/tags/ref_av_dom.asp – DLeh Jan 15 '15 at 20:53
  • don't put code in comments, update your question with more info if more info is needed to convey your problem – DLeh Jan 15 '15 at 21:05
  • Is question in acceptable format? – user3726262 Jan 15 '15 at 21:59

0 Answers0