system beep sound in an xaml file

3 posts, 0 answers
  1. Meenu
    Meenu avatar
    8 posts
    Member since:
    Mar 2013

    Posted 19 Aug 2013 Link to this post

    how can I write code for  playing  system beep sound in an xaml file?

    I tried Console.beep() But not working
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Aug 2013 Link to this post

    Hi Meenu,

    Console.beep() plays the sound of a beep through the console speaker alone. Apart from this in SilverLight you have a plethora of sound capabilities; one of which is using the MediaElement control. So, you could add one of those to your page as shown below.

    XAML:
    <MediaElement x:Name="beeper"></MediaElement>

    C#:
    private void AssignBeep()
    {
      Uri beepUri = new Uri("Project;component/beep.mp3", UriKind.RelativeOrAbsolute);
      StreamResourceInfo streamInfo = Application.GetResourceStream(beepUri);
      this.beeper.SetSource(streamInfo.Stream);
      this.beeper.AutoPlay = false;
    }
     
    private void PlayBeep()
    {
      this.beeper.Position = new TimeSpan(0,0,0,0);
      this.beeper.Volume = 1;
      this.beeper.Play();
    }

    Also you can try the SilverSynth.

    Thanks,
    Shinu.
  3. DevCraft banner
  4. Meenu
    Meenu avatar
    8 posts
    Member since:
    Mar 2013

    Posted 21 Aug 2013 Link to this post

    Yes...Done..>Working perfect....Thank u so much.....

    I added mp3 file build action to resource
Back to Top