I am using the Raspbian “wheezy” image and I copied over a wav file and played it successfully doing:
aplay test.wav
So then I knocked up this little console application:
using System;
using System.Media;
using System.IO;
namespace SoundPlayingTest
{
class MainClass
{
public static void Main (string[] args)
{
using(var file = new FileStream("test.wav",
FileMode.Open, FileAccess.Read, FileShare.Read))
{
var player = new SoundPlayer(file);
player.PlaySync();
}
}
}
}
I expected that to play the wav just like aplay but it finishes (with no error) and I hear nothing from the headphones I have plugged in.
I found this thread "System.Media.SoundPlayer silent" that suggested it wasn't working but was fixed and the workaround suggested there is exactly what I am doing so I am not really any further.
To give some further information I ran:
mono --version
And this was the result:
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-5)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: normal
Notifications: epoll
Architecture: armel,vfp
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
So, is it possible to get SoundPlayer to work (it should play a wav file right?) or is there some alternative I can use in order to play a sound file from mono running on the PI?
(by the way, I installed mono by doing sudo apt-get install mono-complete so I guess I am not missing any dependencies)