TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nicole castel
NA
208
47.8k
Play sound in a loop
Jun 17 2011 4:40 PM
Hello
I have a play function wich plays sound file in all the card soundes related to my pc but when try to play a sound file in a loop,the function play sound in a loop but it stops playing it in alla available devices,this is my playsoud function:
public 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);
outputDevices[deviceNumber] = new PlaybackSession { WaveOut = waveOut, WaveStream = waveReader };
// LoopStream loop = new LoopStream(waveReader);
// waveOut = new WaveOut();
// waveOut.Init(loop);
waveOut.Init(waveReader);
waveOut.Play();
// hold onto the WaveOut and WaveStream so we can dispose them later
}
private Dictionary<int, PlaybackSession> outputDevices = new Dictionary<int, PlaybackSession>();
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);
}
Please can you give me an idea or a code ? thank you in advance ,good day
Reply
Answers (
4
)
cant find name in my dataTable
Attach dll