Пример #1
0
        async Task <bool> PlayStream()
        {
            streamOfflineBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

            if (qualities == null)
            {
                // stream offline
                streamOfflineBlock.Visibility             = Windows.UI.Xaml.Visibility.Visible;
                liveViewersBlock.Text                     = "Offline";
                playPauseButton.Label                     = "Play";
                ((SymbolIcon)playPauseButton.Icon).Symbol = Symbol.Play;
                totalViewersBlock.Text                    = channel.views.ToString();
                followersBlock.Text = channel.followers.ToString();
                return(false);
            }

            AppConstants.PlayPreferredQuality(qualities, AppConstants.Quality.Source, streamerObject);
            stream = await AppConstants.twixel.RetrieveStream(channel.name);

            videoPlaying           = true;
            liveViewersBlock.Text  = stream.viewers.ToString();
            totalViewersBlock.Text = channel.views.ToString();
            followersBlock.Text    = channel.followers.ToString();
            streamerObject.SetTrackTitle(stream.channel.displayName, channel.status);
            streamerObject.SetThumbnail(stream.channel.logo.urlString);
            return(true);
        }
Пример #2
0
 void StartStream(Uri streamUrl)
 {
     Debug.WriteLine("Starting stream");
     streamerObject.SetStreamUrl(streamUrl);
     streamerObject.SetTrackTitle(stream.channel.displayName, stream.channel.status);
     if (stream.channel.logo != null)
     {
         streamerObject.SetThumbnail(stream.channel.logo.urlString);
     }
     streamerObject.StartStream();
     videoPlaying = true;
 }
Пример #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            AppConstants.DeterminePreferredQuality();
            await AppConstants.SetText("Twixel");

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

            topGamesCollection  = new ObservableCollection <GameGridViewBinding>();
            justFetchedTopGames = new List <Game>();
            justFetchedTopGames = await AppConstants.twixel.RetrieveTopGames(10, false);

            if (justFetchedTopGames != null)
            {
                foreach (Game game in justFetchedTopGames)
                {
                    topGamesCollection.Add(new GameGridViewBinding(game));
                }
            }
            else
            {
                await AppConstants.ShowError("Could not load top games.\nError Code: " + AppConstants.twixel.ErrorString);
            }

            featuredStreams = await AppConstants.twixel.RetrieveFeaturedStreams(5, false);

            if (featuredStreams != null)
            {
                if (featuredStreams.Count > 0)
                {
                    selectedStreamIndex               = 0;
                    backStreamButton.IsEnabled        = false;
                    featuredGameTextBlock.Text        = featuredStreams[selectedStreamIndex].stream.channel.displayName + " playing " + featuredStreams[selectedStreamIndex].stream.game;
                    featuredDescriptionTextBlock.Text = FixDescription(featuredStreams[selectedStreamIndex].text);
                    qualities = await AppConstants.GetQualities(featuredStreams[selectedStreamIndex].stream.channel.name);

                    if (qualities == null)
                    {
                        streamOfflineTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
                        streamIsOffline           = true;
                        pausePlayButton.IsEnabled = false;
                    }
                    else
                    {
                        streamerObject.SetTrackTitle(featuredStreams[selectedStreamIndex].stream.channel.displayName, featuredDescriptionTextBlock.Text);
                        streamerObject.SetThumbnail(featuredStreams[selectedStreamIndex].stream.channel.logo.urlString);
                        AppConstants.PlayPreferredQuality(qualities, AppConstants.preferredQuality, streamerObject);
                        videoPlaying = true;
                    }
                }
            }
            else
            {
                await AppConstants.ShowError("Could not load featured streams.\nError Code: " + AppConstants.twixel.ErrorString);
            }
        }