Hi
I have been trying to use the, playbackstopped eventhandler on the wavout class. I am trying to get a playlist to cycle through audio tracks so at the end of each track it evaluates the playlist and plays the next valid track. For some reason NAudio crashes when I do this at the .init() call I have had a look at the PlaybackStatus and it seems to still be at Playing when the playbackstopped event is or has been called.
Any suggestions....
if you want my project off me please give me a shout moogus@hotmail.co.uk
Darren
Comments: Hi Thanks for the response. I was just using the playbackstopped event to start another track. The action being passed in is the playlist initiating the next track. I traced it through the sample code version and when the playbackstopped event fires the state is not stopped could this be the why? Any advice would be cool. Darren private static IWavePlayer _waveOutDevice; private static WaveStream _mainOutputStream; public NAudioPlayFile() { _waveOutDevice = new WaveOut(); } public void OnTrackStopped(Action action) { _waveOutDevice.PlaybackStopped += (sender, args) => action(); } public void InitializeAudioTrack(string source) { _mainOutputStream = new AudioFileReader(source); } public PlaybackState PlaybackState { get { return _waveOutDevice.PlaybackState; } } public void PlayFile() { _waveOutDevice.Init(_mainOutputStream); _waveOutDevice.Play(); } public void CancelTrack() { _waveOutDevice.Stop(); _waveOutDevice.Dispose(); }
I have been trying to use the, playbackstopped eventhandler on the wavout class. I am trying to get a playlist to cycle through audio tracks so at the end of each track it evaluates the playlist and plays the next valid track. For some reason NAudio crashes when I do this at the .init() call I have had a look at the PlaybackStatus and it seems to still be at Playing when the playbackstopped event is or has been called.
Any suggestions....
if you want my project off me please give me a shout moogus@hotmail.co.uk
Darren
Comments: Hi Thanks for the response. I was just using the playbackstopped event to start another track. The action being passed in is the playlist initiating the next track. I traced it through the sample code version and when the playbackstopped event fires the state is not stopped could this be the why? Any advice would be cool. Darren private static IWavePlayer _waveOutDevice; private static WaveStream _mainOutputStream; public NAudioPlayFile() { _waveOutDevice = new WaveOut(); } public void OnTrackStopped(Action action) { _waveOutDevice.PlaybackStopped += (sender, args) => action(); } public void InitializeAudioTrack(string source) { _mainOutputStream = new AudioFileReader(source); } public PlaybackState PlaybackState { get { return _waveOutDevice.PlaybackState; } } public void PlayFile() { _waveOutDevice.Init(_mainOutputStream); _waveOutDevice.Play(); } public void CancelTrack() { _waveOutDevice.Stop(); _waveOutDevice.Dispose(); }