Esempio n. 1
0
        private async void streamPlayer_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            if (fullScreen)
            {
                topBar.Visibility    = Windows.UI.Xaml.Visibility.Visible;
                bottomBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
                fullScreen           = false;
            }
            else
            {
                topBar.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
                bottomBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                fullScreen           = true;
            }

            qualities = await AppConstants.GetQualities(stream.channel.name);

            if (CheckOffline())
            {
                streamOffline = true;
            }

            if (!streamOffline)
            {
                stream = await AppConstants.twixel.RetrieveStream(stream.channel.name);

                if (stream != null)
                {
                    streamDescription.Text = stream.channel.status;
                    streamerName.Text      = stream.channel.displayName;
                    streamGame.Text        = stream.game;
                    streamViewers.Text     = stream.viewers.ToString();
                }
            }
        }
Esempio n. 2
0
        private async void forwardStreamButton_Click(object sender, RoutedEventArgs e)
        {
            selectedStreamIndex++;
            backStreamButton.IsEnabled        = true;
            streamOfflineTextBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            streamIsOffline           = false;
            pausePlayButton.IsEnabled = true;
            if (selectedStreamIndex == featuredStreams.Count - 1)
            {
                forwardStreamButton.IsEnabled = false;
            }
            streamerObject.Stop();
            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;
            }

            if (videoPlaying)
            {
                streamerObject.SetTrackTitle(featuredStreams[selectedStreamIndex].stream.channel.displayName, featuredDescriptionTextBlock.Text);
                streamerObject.SetThumbnail(featuredStreams[selectedStreamIndex].stream.channel.logo.urlString);
                AppConstants.PlayPreferredQuality(qualities, AppConstants.preferredQuality, streamerObject);
            }
        }
Esempio n. 3
0
        public async void PlayPauseAction()
        {
            if (videoPlaying)
            {
                streamerObject.Stop();
                videoPlaying = false;
                ((SymbolIcon)pausePlayButton.Icon).Symbol = Symbol.Play;
            }
            else
            {
                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
                {
                    AppConstants.PlayPreferredQuality(qualities, AppConstants.preferredQuality, streamerObject);
                    videoPlaying = true;
                    ((SymbolIcon)pausePlayButton.Icon).Symbol = Symbol.Pause;
                }
            }
        }
Esempio n. 4
0
        private async void streamStreamButton_Click(object sender, RoutedEventArgs e)
        {
            List <object> parameters = new List <object>();

            parameters.Add(featuredStreams[selectedStreamIndex].stream);
            qualities = await AppConstants.GetQualities(featuredStreams[selectedStreamIndex].stream.channel.name);

            parameters.Add(qualities);
            Frame.Navigate(typeof(StreamPage), parameters);
        }
Esempio n. 5
0
        async void PlayReloadStream()
        {
            qualities = await AppConstants.GetQualities(stream.channel.name);

            if (CheckOffline())
            {
                return;
            }

            PlayStream();
        }
Esempio n. 6
0
        private async void followingGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            GameStreamsGridViewBinding streamItem = (GameStreamsGridViewBinding)e.ClickedItem;

            List <object> parameters = new List <object>();

            parameters.Add(streamItem.stream);
            Dictionary <AppConstants.Quality, Uri> qualities = await AppConstants.GetQualities(streamItem.stream.channel.name);

            parameters.Add(qualities);
            Frame.Navigate(typeof(StreamPage), parameters);
        }
Esempio n. 7
0
        private async void streamButton_Click(object sender, RoutedEventArgs e)
        {
            List <object> parameters = new List <object>();

            TwixelAPI.Stream stream;
            try
            {
                stream = await AppConstants.twixel.RetrieveStream(channel.name);
            }
            catch
            {
                streamButton.IsEnabled = false;
                streamButton.Label     = "Stream Offline";
                return;
            }
            parameters.Add(stream);
            Dictionary <AppConstants.Quality, Uri> qualities = await AppConstants.GetQualities(channel.name);

            parameters.Add(qualities);
            Frame.Navigate(typeof(StreamPage), parameters);
        }
Esempio n. 8
0
        private async void AppBar_Opened(object sender, object e)
        {
            qualities = await AppConstants.GetQualities(stream.channel.name);

            if (CheckOffline())
            {
                streamOffline = true;
            }

            if (!streamOffline)
            {
                stream = await AppConstants.twixel.RetrieveStream(stream.channel.name);

                if (stream != null)
                {
                    streamDescription.Text = stream.channel.status;
                    streamerName.Text      = stream.channel.displayName;
                    streamGame.Text        = stream.game;
                    streamViewers.Text     = stream.viewers.ToString();
                }
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (AppConstants.ActiveUser != null)
            {
                if (AppConstants.ActiveUser.authorized)
                {
                    user = AppConstants.ActiveUser;
                    userNameBlock.Text = user.displayName;
                    userButton.Content = AppConstants.ActiveUser.displayName;
                    BitmapImage bitmapImage = new BitmapImage(user.logo.url);
                    profileImage.Source = bitmapImage;

                    channel = await user.RetrieveChannel();

                    statusTextBox.Text = channel.status;
                    if (channel.game != null)
                    {
                        gameTextBox.Text = channel.game;
                    }
                    else
                    {
                        gameTextBox.Text = "";
                    }

                    qualities = await AppConstants.GetQualities(channel.name);

                    await PlayStream();
                }
            }

            justLaunchedPage = false;
            ElementsLoaded();

            streamsFollowed = await user.RetrieveOnlineFollowedStreams();

            foreach (TwixelAPI.Stream stream in streamsFollowed)
            {
                followedLiveStreamsCollection.Add(new GameStreamsGridViewBinding(stream));
            }

            channelsFollowed = await user.RetrieveFollowing(100);

            foreach (Channel followedChannel in channelsFollowed)
            {
                if (followedChannel.logo != null)
                {
                    followedProfilesCollection.Add(new FollowersGridViewBinding(followedChannel.logo.urlString, followedChannel.displayName));
                }
                else
                {
                    followedProfilesCollection.Add(new FollowersGridViewBinding(null, followedChannel.displayName));
                }
                followedProfilesCollection[followedProfilesCollection.Count - 1].Channel = followedChannel;
            }

            blockedUsers = await user.RetrieveBlockedUsers();

            foreach (User blockedUser in blockedUsers)
            {
                blockedUsersCollection.Add(new FollowersGridViewBinding(blockedUser));
            }

            channelEditors = await user.RetrieveChannelEditors();

            foreach (User channelEditor in channelEditors)
            {
                channelEditorsCollection.Add(new FollowersGridViewBinding(channelEditor));
            }
        }