NAudio playing music before function is even called
NAudio playing music before function is even called
WaveOutEvent player = new WaveOutEvent();
WaveChannel32 volumeChannel = new WaveChannel32(waveStream);
player.Init(volumeChannel);
Multimedia.Timer musicdelayer = new Multimedia.Timer();
musicdelayer.Mode = Multimedia.TimerMode.OneShot;
musicdelayer.Tick += Musicdelayer_Tick;
musicdelayer.Period = (offset < 0) ? Math.Abs(offset) : 1;
Tick Event:
private void Musicdelayer_Tick(object sender, EventArgs e)
Console.WriteLine("tick");
player.Play();
Now something incredibly strange happens:
The console outputs "tick" 5 seconds after the tick event is called with the offset of -5000... but the player has started playing already instantly before tick is even called.. what the hell?
I am just confused out of my mind to how this is happening. Any idea what might be going on?
1 Answer
1
Apparently pausing it first seems to solve the issue... strange
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy