locked
Play audio on click and stop on another click RRS feed

  • Question

  • Here is what I am trying to accomplish -

    I click on an image, it pops up and plays a sound. When I click on the popup image/div, I want the audio to stop and hide the div.

    Here is the code I have written:

    var music = newAudio("");

    (function () {

    ...

    ui.Pages.define(...), {

    ....

    _myfun: function (args) {

    ...

    music.src="alpha.wav";

    music.play();

    }

    });

    })();

    function divclick() {

    music.stop();

    }

    In html I have the onclick of div defined to divclick()

    My music is playing properly, but when it comes to divclick(), it says stop is not identified. How do I get the music to stop on click?

    Thanks,

    Nisha

    Tuesday, December 4, 2012 10:20 PM

Answers

  • As far as I can see, there is no stop method, just play and pause.

    http://msdn.microsoft.com/en-us/library/windows/apps/hh441227.aspx#methods

    • Marked as answer by Nisha Tuesday, December 4, 2012 10:40 PM
    Tuesday, December 4, 2012 10:36 PM

All replies

  • As far as I can see, there is no stop method, just play and pause.

    http://msdn.microsoft.com/en-us/library/windows/apps/hh441227.aspx#methods

    • Marked as answer by Nisha Tuesday, December 4, 2012 10:40 PM
    Tuesday, December 4, 2012 10:36 PM
  • Thanks.. I changed it to pause and it worked!
    Tuesday, December 4, 2012 10:40 PM