I have a function that allows me play a sound file located in a database in all sound cards installed in my pc.I uses Naudio library.
How can I
repeat reading this file sound automatically and thank you in advance for your helpers
Here is my code:
private void PlaySoundInDevice(int deviceNumber, string fileName)
{
if (outputDevices.ContainsKey(deviceNumber))
{
outputDevices[deviceNumber].WaveOut.Dispose();
outputDevices[deviceNumber].WaveStream.Dispose();
}
var waveOut = new WaveOut();
waveOut.DeviceNumber = deviceNumber;
WaveStream waveReader = new WaveFileReader(fileName);
// hold onto the WaveOut and WaveStream so we can dispose them later
outputDevices[deviceNumber] = new PlaybackSession { WaveOut = waveOut, WaveStream = waveReader };
waveOut.Init(waveReader);
waveOut.Play();
}
private Dictionary
class PlaybackSession
{
public IWavePlayer WaveOut { get; set; }
public WaveStream WaveStream { get; set; }
}
private void DisposeAll()
{
foreach (var playbackSession in outputDevices.Values)
{
playbackSession.WaveOut.Dispose();
playbackSession.WaveStream.Dispose();
}
}
public void PlayInAllAvailableDevices(string fileName)
{
int waveOutDevices = WaveOut.DeviceCount;
for (int n = 0; n < waveOutDevices; n++)
{
PlaySoundInDevice(n, fileName);
}
}
sawass sawassPosted May 26, 2011, 9:06 AM
I have another problem.My project allows also broadcast a direct voice message.I want to add a chime function before the start diffusion of the message.It is a function that attracts people's attention like the tone we listen in an airport (ding dong). Will you help me to to do this function.I don't know how I can do and thanks for your help.
FroglegPosted May 25, 2011, 5:20 PM
FroglegPosted May 25, 2011, 5:20 PM
FroglegPosted May 25, 2011, 4:25 PM
http://mark-dot-net.blogspot.com/2009/10/looped-playback-in-net-with-naudio.html