private void RegisterPlaybackInterruptedCallback() { _playbackInterruptedCallback = (code, _) => { if (!Enum.IsDefined(typeof(PlaybackInterruptionReason), code)) { return; } if (code == PlaybackInterruptionReason.ResourceConflict) { OnUnprepared(); } Log.Warn(PlayerLog.Tag, $"interrupted reason : {code}"); PlaybackInterrupted?.Invoke(this, new PlaybackInterruptedEventArgs(code)); }; NativePlayer.SetInterruptedCb(Handle, _playbackInterruptedCallback). ThrowIfFailed(this, "Failed to set PlaybackInterrupted"); }
public void HandleCommandQueued(ICommandSnapshot commandSnapshot) { // Make sure we do not have commands in future before we queue up past commands. // This is a safety net. // One should explicitly call Stop() or EraseFuture(), before any new command is queued. // to be dumped. // TODO: Use seek while (_isPlaying && _futureCommands.Count > 0) { RedoNextCommand(); if (_futureCommands.Count == 0) { PlaybackInterrupted.Invoke(); } } TimeSpan timeFromPreviousCommand = GetClippedTimeFromPreviousCommand(commandSnapshot); ReplaySnapshot replaySnapshot = new ReplaySnapshot(commandSnapshot, timeFromPreviousCommand); _pastCommands.AddLast(replaySnapshot); }