/// <summary>
/// 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.
/// </summary>
/// <param name="sender">Unused params</param>
/// <param name="e">Unused params</param>
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();
}
}