wpf - C# NAudio - Changing audio playback position still plays a small buffer of old position -


i trying make basic mp3 player in c# , wpf, along naudio. added slider tracks current position in song allows drag different position , upon thumb.dragcompleted set song's position dragged it.

this works fine , all, except when make jump new position, still plays old position 1/5th or of second before changing. noticeable e.g. while singer in middle of singing "aaa", pause, drag point sings "ooo", play again, hear "aa-ooo". results in sounding pretty horrible.

so suppose audio playback has small 'buffer' remaining insists on playing before moving on. there way clear buffer? or setting position wrong?

i using waveout waveoutdevice , audiofilereader audiofilereader. slider called sldrplaybackprogress.
tried change position in song in 2 different ways already:

first method:

audiofilereader.currenttime = new timespan(0, (int)(math.floor(sldrplaybackprogress.value / 60)), (int)(math.floor(sldrplaybackprogress.value % 60)));  

second method:

audiofilereader.position = (long)(sldrplaybackprogress.value * audiofilereader.waveformat.averagebytespersecond); 

both of these individually or both combined still result in problem persisting.

you should call stop when reposition happens during pause. flush outstanding buffers and. under hood stop calls waveoutstop , pause calls waveoutpause, doesn't clear in progress playing buffers.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -