Example #1
0
 protected virtual void StopInternal()
 {
     Ended.TrySetResult(true);
     State = PlayState.Stopped;
     AudioLayer.SourceStop(SoundInstance.Source);
     RestartInternal();
 }
Example #2
0
 /// <summary>
 /// Restarts streaming from the beginning.
 /// </summary>
 protected void Restart()
 {
     ReadyToPlay.TrySetResult(false);
     ReadyToPlay = new TaskCompletionSource <bool>();
     Ended.TrySetResult(false);
     Ended            = new TaskCompletionSource <bool>();
     readyToPlay      = false;
     prebufferedCount = 0;
 }
Example #3
0
        protected virtual void PlayInternal()
        {
            switch (State)
            {
            case PlayState.Playing:
                break;

            case PlayState.Paused:
                AudioLayer.SourcePlay(SoundInstance.Source);
                break;

            case PlayState.Stopped:
                Ended.TrySetResult(false);
                Ended = new TaskCompletionSource <bool>();
                PlayAsyncInternal();
                break;
            }
            PlayingQueued = false;
            State         = PlayState.Playing;
        }
Example #4
0
 void Player_Completion(object sender, EventArgs e) => Thread.Pool.RunAction(async() =>
 {
     Ended.TrySetResult(true);
     await Completed.Raise();
 });
Example #5
0
 Task StopPlaying()
 {
     Player?.Stop();
     Thread.Pool.RunAction(() => Ended.TrySetResult(false));
     return(Task.CompletedTask);
 }
Example #6
0
 void Player_MediaEnded(Windows.Media.Playback.MediaPlayer sender, object args)
 {
     Ended.TrySetResult(true);
 }
Example #7
0
 void Player_FinishedPlaying(object sender, AVStatusEventArgs e)
 {
     Ended.TrySetResult(true);
     Completed.Raise().RunInParallel();
 }