Question

I'm writing a crossplatform program which displays a timer either counting up or down to a user set interval. At the end of that interval I want to play a sound. I thought using something like :

System.Media.SystemSounds.Beep.Play();

would work. I have no indication of failure other than no sound is played on my Mac. When I wrote a little test piece of code with a "button" to trigger the "beep" sound, it did not play. However, the above code snippet works fine on my wife's Windows Vista machine (also using MonoDevelop 2.8.8.4). Ironically, it also works fine on a sandboxed Ubuntu 12.04 linux (MonoDevelop 2.8.6.3) which I sandboxed on my Mac by way of VirtualBox.

I've looked around on SO, and on the internet but I can't find any satisfying answers to this puzzle. Let me ask the question again. "What stops my Mac from playing the "Beep" sound in my program on my Mac, yet a sandboxed linux on that same mac has no problem playing the sound?"

Thanks for any help on this.

Was it helpful?

Solution

Looking at Mono's implementation of System.Media, it seem it's only implemented for ALSA (one of the Linux sounds systems) and Windows. I suspect it's because System.Media is a very simple sound API that can't do very much, so is rarely used.

I can't think of any good platform agnostic sound player API, thought the GTK# UI toolkit (used by MonoDevelop) has a Display.Beep() that AFAIK works on all platforms. If your app is a terminal app you might also try System.Console.Beep ().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top