Example #1
0
        private void BindSubtitleStreamPicker()
        {
            var streams = new List <StreamDescription>
            {
                new StreamDescription
                {
                    Default     = true,
                    Description = "off",
                    Id          = 0,
                    Type        = StreamDescription.StreamType.Subtitle
                }
            };

            streams.AddRange(_playerService.GetStreamsDescription(StreamDescription.StreamType.Subtitle));

            InitializePicker(Subtitles, streams);

            SelectDefaultStreamForPicker(Subtitles, streams);

            Subtitles.SelectedIndexChanged += (sender, args) =>
            {
                if (Subtitles.SelectedIndex == -1)
                {
                    return;
                }

                if (Subtitles.SelectedIndex == 0)
                {
                    _playerService.DeactivateStream(StreamDescription.StreamType.Subtitle);
                    return;
                }

                var stream = (StreamDescription)Subtitles.ItemsSource[Subtitles.SelectedIndex];
                try
                {
                    _playerService.ChangeActiveStream(stream);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    Subtitles.SelectedIndex = 0;
                }
            };
        }
Example #2
0
        public void ControlSelect(IPlayerService player)
        {
            if (player == null)
            {
                return;
            }

            int selectedStreamTypeIndex = _selectedOption;
            int selectedStreamIndex     = _selectedSubOption;

            if (selectedStreamIndex >= 0 && selectedStreamIndex < _streams[selectedStreamTypeIndex].Descriptions.Count)
            {
                if (_streams[selectedStreamTypeIndex].Descriptions[selectedStreamIndex].StreamType == StreamType.Subtitle && selectedStreamIndex == 0) // special subtitles:off sub option
                {
                    SubtitlesOn = false;
                    player.DeactivateStream(StreamType.Subtitle);
                }
                else
                {
                    try
                    {
                        player.ChangeActiveStream(_streams[selectedStreamTypeIndex].Descriptions[selectedStreamIndex]);
                        if (_streams[selectedStreamTypeIndex].Descriptions[selectedStreamIndex].StreamType == StreamType.Subtitle)
                        {
                            SubtitlesOn = true;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e);
                        if (_streams[selectedStreamTypeIndex].Descriptions[selectedStreamIndex].StreamType ==
                            StreamType.Subtitle)
                        {
                            SubtitlesOn         = false;
                            selectedStreamIndex = 0;
                        }
                    }
                }

                _streams[selectedStreamTypeIndex].Active = selectedStreamIndex;
                _activeSubOption = selectedStreamIndex;
            }

            UpdateOptionsSelection();
        }
Example #3
0
 public Task ChangeActiveStream(StreamDescription streamDescription)
 {
     return(playerThread.Factory.StartNew(async() => await proxied.ChangeActiveStream(streamDescription)));
 }
Example #4
0
 public void ChangeActiveStream(StreamDescription streamDescription)
 {
     playerThread.Factory.StartNew(() => proxied.ChangeActiveStream(streamDescription));
 }