naudio / varispeed-sample

Showing how to use NAudio with SoundTouch for varispeed playback
34 stars 7 forks source link

PlaybackState Error #1

Open pluto6322 opened 2 years ago

pluto6322 commented 2 years ago

When using VarispeedSample Providerd, PlaybackState is always playing , It doesn't change when MP3 playback ends..

thanks for viewing

markheath commented 2 years ago

Some providers always provide the full amount of audio requested in Read, regardless of whether the source stream has reached the end or not. In that case the audio will play forever and you need an alternative mechanism to detect that you have reached the end of the file.

VRCWizard commented 1 year ago

I wish a solution was provided here. x_x ... i figured out that varispeed was causing "MemoryAllocationError calling waveOutWrite" when spammed because it is always playing.

edit: instead of checking playbackstate for stopped you can get the TotalTime.TotalMilliseconds of the wavefilereader or whatever you are passing into the varispeedSampleProvider. You can then sleep until that time has passed then dispose of everything.

(if you slow down the audio by .5 it would take twice as long to complete so you would have to multiply the time you sleep by 2.)