private void ResumePlayback() { player.Resume(); StartClockGenerator(); _dataClock.Start(); logger.Info(""); }
/// <summary> /// Starts playback on all initialized streams. Streams do have to be /// configured in order for the call to start playback. /// </summary> public void Play() { if (!AllStreamsConfigured) { logger.Info("Initialized streams are not configured. Start will occur after receiving configurations"); return; } try { var token = activeTaskCts.Token; token.ThrowIfCancellationRequested(); var state = player.GetState(); logger.Info($"{state}"); switch (state) { case ESPlayer.ESPlayerState.Playing: return; case ESPlayer.ESPlayerState.Ready: player.Start(); break; case ESPlayer.ESPlayerState.Paused: StartClockGenerator(); player.Resume(); ResumeTransfer(token); break; default: throw new InvalidOperationException($"Play called in invalid state: {state}"); } SetState(PlayerState.Playing); } catch (InvalidOperationException ioe) { logger.Error(ioe); } catch (OperationCanceledException) { logger.Info("Operation cancelled"); } }
/// <summary> /// Starts playback on all initialized streams. Streams do have to be /// configured in order for the call to start playback. /// </summary> public async void Play() { logger.Info(""); if (!AllStreamsConfigured) { logger.Info("Initialized streams are not configured. Start will occur after receiving configurations"); return; } try { if (resourceConflict) { logger.Info("Player Resource conflict. Trying to restart"); var token = activeTaskCts.Token; await RestartPlayer(token); return; } var state = player.GetState(); switch (state) { case ESPlayer.ESPlayerState.Playing: return; case ESPlayer.ESPlayerState.Ready: player.Start(); break; case ESPlayer.ESPlayerState.Paused: player.Resume(); break; default: throw new InvalidOperationException($"Play called in invalid state: {state}"); } EnableTransfer(); StartClockGenerator(); stateChangedSubject.OnNext(PlayerState.Playing); } catch (InvalidOperationException ioe) { logger.Error(ioe); } }
/// <summary> /// Starts playback on all initialized streams. Streams do have to be /// configured in order for the call to start playback. /// </summary> public void Play() { if (!AllStreamsHaveConfiguration) { logger.Info($"Needed config: Video {esStreams[(int)StreamType.Video].Configuration == null} Audio {esStreams[(int)StreamType.Audio].Configuration == null}"); return; } try { var token = activeTaskCts.Token; token.ThrowIfCancellationRequested(); var state = player.GetState(); logger.Info($"Player State: {state}"); switch (state) { case ESPlayer.ESPlayerState.Playing: return; case ESPlayer.ESPlayerState.Ready: player.Start(); try { using (asyncOpSerializer.Lock(new CancellationToken(true))) { StartClockGenerator(); SubscribeBufferingEvent(); } } catch (OperationCanceledException) { logger.Info("Async operation in progress."); } break; case ESPlayer.ESPlayerState.Paused: _pauseReason = PauseReason.NotPaused; if (_pendingRepresentation != null) { logger.Info("Pending ChangeRepresentation()"); _ = ChangeRepresentationInternal(_pendingRepresentation, true, token); } else { ResumeTransfer(token); player.Resume(); _dataClock.Start(); SubscribeBufferingEvent(); } break; default: throw new InvalidOperationException($"Play called in invalid state: {state}"); } SetState(PlayerState.Playing, token); logger.Info("End"); } catch (InvalidOperationException ioe) { logger.Error(ioe); } catch (OperationCanceledException) { logger.Info("Operation canceled"); } }