Пример #1
0
        public SettingsFlyoutStreaming()
        {
            this.InitializeComponent();

            InterfaceHelpers.SetupVideoBitrate(videoBitrate);
            InterfaceHelpers.SetupVideoMaxWidth(videoMaxWidth);
            InterfaceHelpers.SetupAudioBitrate(audioBitrate);
            InterfaceHelpers.SetupAudioChannel(audioChannels);
            InterfaceHelpers.SetupAudioCodec(audioCodecs);
            InterfaceHelpers.SetupEnableStreamCopy(enableStreamCopy);
        }
Пример #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            PointerEventHandler pointerpressedhandler = new PointerEventHandler(slider_PointerEntered);

            playbackProgress.AddHandler(Control.PointerPressedEvent, pointerpressedhandler, true);

            PointerEventHandler pointerreleasedhandler = new PointerEventHandler(slider_PointerCaptureLost);

            playbackProgress.AddHandler(Control.PointerCaptureLostEvent, pointerreleasedhandler, true);

            mediaPlayer.MediaFailed += mediaPlayer_MediaFailed;

            mediaPlayer.InteractiveActivationMode = Microsoft.PlayerFramework.InteractionType.None;

            mediaPlayer.BufferingProgressChanged += mediaPlayer_BufferingProgressChanged;

            mediaPlayer.PlayerStateChanged += mediaPlayer_PlayerStateChanged;

            videoBitrateSelected     = InterfaceHelpers.SetupVideoBitrate(videoBitrate);
            videoMaxWidthSelected    = InterfaceHelpers.SetupVideoMaxWidth(videoMaxWidth);
            audioBitrateSelected     = InterfaceHelpers.SetupAudioBitrate(audioBitrate);
            audioChannelSelected     = InterfaceHelpers.SetupAudioChannel(audioChannels);
            audioCodecSelected       = InterfaceHelpers.SetupAudioCodec(audioCodecs);
            enableStreamCopySelected = InterfaceHelpers.SetupEnableStreamCopy(enableStreamCopy);

            videoBitrate.SelectionChanged     += videoBitrate_SelectionChanged;
            videoMaxWidth.SelectionChanged    += videoMaxWidth_SelectionChanged;
            audioBitrate.SelectionChanged     += audioBitrate_SelectionChanged;
            audioChannels.SelectionChanged    += audioChannels_SelectionChanged;
            audioCodecs.SelectionChanged      += audioCodecs_SelectionChanged;
            enableStreamCopy.SelectionChanged += enableStreamCopy_SelectionChanged;

            // reset session info controls
            transcodeInfoACodec.Text   = ": -";
            transcodeInfoVCodec.Text   = ": -";
            transcodeInfoBitrate.Text  = ": -";
            transcodeInfoSpeed.Text    = ": -";
            transcodeInfoComplete.Text = ": -";
            playbackInfoBuffer.Text    = ": -";
            transcodingProgress.Value  = 0;

            // process the play action
            JObject playRequestData = e.Parameter as JObject;

            MediaItem mediaItem  = null;
            long      startIndex = 0;

            try
            {
                JObject data = (JObject)playRequestData["Data"];
                if (data["StartPositionTicks"] != null)
                {
                    startIndex = (long)data["StartPositionTicks"];
                    startIndex = (startIndex / 1000) / 10000;
                }
                JArray itemIds = (JArray)data["ItemIds"];

                itemId = (string)itemIds[0];

                mediaItem = await client.GetItemInfo(itemId);
            }
            catch (Exception exception)
            {
                App.AddNotification(new Notification()
                {
                    Title = "Error Retreiving Playback Info", Message = exception.Message
                });
            }

            // set up audio and subtitle selection
            List <ComboBoxData> audioStreamItems = new List <ComboBoxData>();

            audioStreamItems.Add(new ComboBoxData()
            {
                DataName = "Auto", DataValueInt = -1
            });
            foreach (MediaStreamInfo mInfo in mediaItem.mediaStreams)
            {
                if (mInfo.Type == "Audio")
                {
                    string langString = mInfo.Language;
                    if (string.IsNullOrWhiteSpace(langString))
                    {
                        langString = "NoLang";
                    }
                    audioStreamItems.Add(new ComboBoxData()
                    {
                        DataName = langString + " (" + mInfo.Codec + ")", DataValueInt = mInfo.Index
                    });
                }
            }
            audioStreamSelector.ItemsSource       = audioStreamItems;
            audioStreamSelector.SelectedIndex     = 0;
            audioStreamSelector.SelectionChanged += audioStreamSelector_SelectionChanged;

            List <ComboBoxData> subStreamItems = new List <ComboBoxData>();

            subStreamItems.Add(new ComboBoxData()
            {
                DataName = "Auto", DataValueInt = -1
            });
            foreach (MediaStreamInfo mInfo in mediaItem.mediaStreams)
            {
                if (mInfo.Type == "Subtitle")
                {
                    string langString = mInfo.Language;
                    if (string.IsNullOrWhiteSpace(langString))
                    {
                        langString = "NoLang";
                    }
                    subStreamItems.Add(new ComboBoxData()
                    {
                        DataName = langString + " (" + mInfo.Codec + ")", DataValueInt = mInfo.Index
                    });
                }
            }
            subStreamSelector.ItemsSource       = subStreamItems;
            subStreamSelector.SelectedIndex     = 0;
            subStreamSelector.SelectionChanged += subStreamSelector_SelectionChanged;

            string logoItemId = "";

            if ((mediaItem.Type).Equals("Episode", StringComparison.OrdinalIgnoreCase))
            {
                logoItemId      = mediaItem.SeriesId;
                mediaTitle.Text = mediaItem.Series + " (" + mediaItem.Year + ") " + mediaItem.Name + " (s" + mediaItem.Season + "e" + mediaItem.EpisodeIndex + ")";
            }
            else if ((mediaItem.Type).Equals("Movie", StringComparison.OrdinalIgnoreCase))
            {
                logoItemId      = mediaItem.Id;
                mediaTitle.Text = mediaItem.Name + " (" + mediaItem.Year + ")";
            }
            else
            {
                mediaTitle.Text = "Unknown Media Type : " + mediaItem.Type;
            }

            // Set media item logo
            string      logoPath = "http://" + settings.GetServer() + "/mediabrowser/Items/" + logoItemId + "/Images/Logo";
            BitmapImage image    = new BitmapImage(new Uri(logoPath, UriKind.Absolute));

            mediaItemLogo.Source = image;

            // start playback
            SetupTimer();

            playbackProgress.Minimum = 0;
            playbackProgress.Maximum = mediaItem.Duration;

            mediaDuration.Text = new TimeSpan(0, 0, (int)mediaItem.Duration).ToString(@"hh\:mm\:ss");

            PlaybackAction(startIndex);

            // set player full screen if required
            bool playFullscreen = settings.GetAppSettingBool("player_start_fullscreen");

            if (playFullscreen)
            {
                gridAreaTitle.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
                gridAreaProgress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                gridAreaInfo.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }