locked
sound in windows 7.1 app RRS feed

  • Question

  • hello

    im trying to make a sound box application for windows mobile 7.1 with c# and visual studio but im having a hard time adding a sound to the button, so ur help is really appreciated.

    Tuesday, May 14, 2013 9:00 AM

All replies

  • hello

    im trying to make a sound box application for windows mobile 7.1 with c# and visual studio but im having a hard time adding a sound to the button, so ur help is really appreciated.

    Hi dev21232,

    you can use the SoundEffect class from the XNA framework to play sounds in Windows Phone 7.1. Here's how:

    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio;

    And in your button's click event handler:

    var stream = TitleContainer.OpenStream("Assets/tada.wav");
    var soundEffect = SoundEffect.FromStream(stream);
    FrameworkDispatcher.Update();
    soundEffect.Play();
    Make sure that the file is in the WAV format and resides in the app package.

    --
    Kind regards,
    Christian

    Tuesday, May 14, 2013 3:45 PM