wpf_player.AudioPlayerModel.wc_Sample C# (CSharp) Method

wc_Sample() private method

This callback is called everytime a sample is player. This method handles current time and current position updates, the stop of the playing at the end of the track and the buffering state.
private wc_Sample ( object sender, NAudio.Wave.SampleEventArgs e ) : void
sender object Unused params
e NAudio.Wave.SampleEventArgs Unused params
return void
        private void wc_Sample(object sender, SampleEventArgs e)
        {
            if (wc == null) return;
            if (wc.CurrentTime.TotalSeconds != currentTime)
            {
                currentTime = wc.CurrentTime.TotalSeconds;
                NotifyPropertyChanged("CurrentTime");
                NotifyPropertyChanged("BufferPortion");
                pos = lmem.Position;
                NotifyPropertyChanged("Position");
            }
            if (lmem.Position == lmem.Length) { this.stop(); return; }
            long myBufferSize = 20480;
            if ((!BufferingState) && (localstream.Position != rsc.Tag.FileSize) && ((localstream.Position - lmem.Position) < myBufferSize))
            {
                Console.WriteLine("Paused ... waiting!");
                BufferingState = true;
                this.pause();
                localstream.WaitForMore();
            }
        }