示例#1
0
        private void HandlePlaybackStart()
        {
            if (PlayerHandle == null)
            {
                PlayerHandle = new Player(_playerWindow);
                PlayerHandle.StateChanged()
                .ObserveOn(SynchronizationContext.Current)
                .Where(state => state == PlayerState.Prepared)
                .Subscribe(state =>
                {
                    if (PlayerHandle == null)
                    {
                        return;
                    }
                    _options.LoadStreamLists(PlayerHandle);
                    PlayerHandle.Start();
                }, () => { _playbackCompletedNeedsHandling = true; });

                PlayerHandle.PlaybackError()
                .ObserveOn(SynchronizationContext.Current)
                .Subscribe(message =>
                {
                    Logger?.Info($"Playback Error: {message}");
                    ReturnToMainMenu();
                    DisplayAlert("Playback Error", message, "OK");
                });

                PlayerHandle.BufferingProgress()
                .ObserveOn(SynchronizationContext.Current)
                .Subscribe(UpdateBufferingProgress);
            }

            Logger?.Info(
                $"Playing {_resourceLoader.ContentList[_selectedTile].Title} ({_resourceLoader.ContentList[_selectedTile].Url})");
            PlayerHandle.SetSource(_resourceLoader.ContentList[_selectedTile]);
            _options.ClearOptionsMenu();
            _seekLogic.IsSeekInProgress = false;
            _bufferingInProgress        = false;
            _bufferingProgress          = 0;
        }