コード例 #1
0
ファイル: UserPage.xaml.cs プロジェクト: dhruveshk/TwixelApp
 void LoadVolumeFlyout()
 {
     if (muteButton != null &&
         volumeSlider != null &&
         loadedVolumeSlider == false)
     {
         loadedVolumeSlider = true;
         volumeFlyout       = new VolumeFlyout(volumeSlider, muteButton, volumeButton, streamPlayer);
     }
 }
コード例 #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            List <object> parameters = (List <object>)e.Parameter;

            stream    = (TwixelAPI.Stream)parameters[0];
            qualities = (Dictionary <AppConstants.Quality, Uri>)parameters[1];

            #region Stream Stuff
            if (CheckOffline())
            {
                return;
            }

            foreach (KeyValuePair <AppConstants.Quality, Uri> quality in qualities)
            {
                ComboBoxItem item = new ComboBoxItem();
                if (quality.Key == AppConstants.Quality.Source)
                {
                    item.Content = "Source";
                }
                else if (quality.Key == AppConstants.Quality.High)
                {
                    item.Content = "High";
                }
                else if (quality.Key == AppConstants.Quality.Medium)
                {
                    item.Content = "Medium";
                }
                else if (quality.Key == AppConstants.Quality.Low)
                {
                    item.Content = "Low";
                }
                else if (quality.Key == AppConstants.Quality.Mobile)
                {
                    item.Content = "Mobile";
                }
                else if (quality.Key == AppConstants.Quality.Chunked)
                {
                    item.Content = "Default";
                }

                streamQualities.Items.Add(item);

                if (streamQualities.Items.Count == 1)
                {
                    streamQualities.SelectedIndex = 0;
                }
            }

            streamDescription.Text = stream.channel.status;
            streamerName.Text      = stream.channel.displayName;
            streamGame.Text        = stream.game;
            streamViewers.Text     = stream.viewers.ToString();

            streamerObject.OnNavigatedTo(stream.channel.displayName, stream.channel.status);

            if ((string)((ComboBoxItem)streamQualities.SelectedItem).Content == "Source")
            {
                StartStream(qualities[AppConstants.Quality.Source]);
            }
            else if ((string)((ComboBoxItem)streamQualities.SelectedItem).Content == "High")
            {
                StartStream(qualities[AppConstants.Quality.High]);
            }
            else if ((string)((ComboBoxItem)streamQualities.SelectedItem).Content == "Medium")
            {
                StartStream(qualities[AppConstants.Quality.Medium]);
            }
            else if ((string)((ComboBoxItem)streamQualities.SelectedItem).Content == "Low")
            {
                StartStream(qualities[AppConstants.Quality.Low]);
            }
            else if ((string)((ComboBoxItem)streamQualities.SelectedItem).Content == "Mobile")
            {
                StartStream(qualities[AppConstants.Quality.Mobile]);
            }
            else if ((string)((ComboBoxItem)streamQualities.SelectedItem).Content == "Default")
            {
                StartStream(qualities[AppConstants.Quality.Chunked]);
            }

            justLaunchedPage = false;
            volumeFlyout     = new VolumeFlyout(volumeSlider, muteButton, volumeButton, streamPlayer);
            chatWindow       = new ChatWindow(Dispatcher, stream.channel.name, chatGrid, chatView, chatBox, chatSendButton);
            await chatWindow.LoadChatWindow();

            #endregion

            if (AppConstants.ActiveUser != null)
            {
                if (AppConstants.ActiveUser.authorized)
                {
                    userButton.Content = AppConstants.ActiveUser.displayName;
                    user = AppConstants.ActiveUser;
                }
                else
                {
                    userButton.Content = "Log In";
                }
            }
            else
            {
                userButton.Content = "Log In";
            }

            if (user != null)
            {
                List <Channel> temp = await user.RetrieveFollowing(100);

                if (temp != null)
                {
                    foreach (Channel channel in temp)
                    {
                        channelsFollowed.Add(channel);
                    }
                }

                do
                {
                    temp = await user.RetrieveFollowing(true);

                    if (temp != null)
                    {
                        foreach (Channel channel in temp)
                        {
                            channelsFollowed.Add(channel);
                        }
                    }
                }while (temp.Count != 0);

                if (user.authorizedScopes.Contains(TwixelAPI.Constants.TwitchConstants.Scope.UserFollowsEdit))
                {
                    foreach (Channel channel in channelsFollowed)
                    {
                        if (channel.name == stream.channel.name)
                        {
                            followButton.Label = "Unfollow";
                            ((SymbolIcon)followButton.Icon).Symbol = Symbol.Clear;
                            break;
                        }
                    }
                }
                else
                {
                    followButton.IsEnabled = false;
                }
            }
            else
            {
                followButton.IsEnabled = false;
            }
        }