wpf_player.AudioPlayerModel.CheckWaitingBuffering C# (CSharp) Method

CheckWaitingBuffering() public method

This method check if the new position is beyond the limit of buffered data; in this case the playback is paused and the player will wait for missing data.
public CheckWaitingBuffering ( long newPosition ) : bool
newPosition long Position that we want to check
return bool
        public bool CheckWaitingBuffering(long newPosition)
        {
            if ((localstream != null) && (newPosition > localstream.Position))
            {
                Console.WriteLine("Too far ... waiting!");
                BufferingState = true;
                //this.pause();
                localstream.WaitForMore(Math.Max(0, (int)(newPosition - localstream.Position)+20480));
                return true;
            } else
            {
                return false;
            }
        }

Usage Example

Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TrackSlider_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            AudioPlayerModel vm = (AudioPlayerModel)this.DataContext;

            vm.EnableFlowRestart = true;
            Slider s = sender as Slider;

            Console.WriteLine("_________" + s.Value);
            if (!vm.CheckWaitingBuffering((long)s.Value))
            {
                vm.Pause.Execute(null);
            }
        }