I am writing a simple timer application for OSX10.6 using Mono. How can I play an audio signal (can it be a wav / mp3 file or something else)?
I tried several ways, unfortunately, no one worked:
NSSound seems to be not yet supported by Mono.
MonoMac.AppKit.NSSound alarm = new MonoMac.AppKit.NSSound("alarm.wav"); alarm.Play();
Using SoundPlayer does not work either:
System.Media.SoundPlayer player = new System.Media.SoundPlayer("alarm.wav"); player.PlaySync();
I was able to play the sound by opening System.Diagnostics.Process , and then using the OSX afplay command line afplay . Unfortunately, this command opens in a new terminal window, which is quite annoying in a graphical application.
I understand that Mono has CoreAudio bindings. But I did not understand how to use them to play sound.
source share