Exemplo n.º 1
0
 private void featuredStreamPlayer_Loaded(object sender, RoutedEventArgs e)
 {
     streamerObject = new StreamerObject(Dispatcher, featuredStreamPlayer, PlayPauseAction);
     streamerObject.StreamerObjectErrorEvent += streamerObject_StreamerObjectErrorEvent;
     streamerObject.OnNavigatedTo("Twixel", "Twixel");
     Unloaded += HomePage_Unloaded;
 }
Exemplo n.º 2
0
 private void streamPlayer_Loaded(object sender, RoutedEventArgs e)
 {
     streamPlayer   = sender as MediaElement;
     streamerObject = new StreamerObject(Dispatcher, streamPlayer, PlayPauseAction);
     streamerObject.StreamerObjectErrorEvent += streamerObject_StreamerObjectErrorEvent;
     streamerObject.OnNavigatedTo("Twixel", "Twixel");
     Unloaded += UserPage_Unloaded;
     ElementsLoaded();
 }
Exemplo n.º 3
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;
            }
        }