Beispiel #1
0
 private async void VolumeSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
 {
     if (SpotifyHelper != null)
     {
         await SpotifyHelper.SetVolume((uint)e.NewValue);
     }
 }
Beispiel #2
0
        public MainPage()
        {
            this.InitializeComponent();

            ranOnLaunchInternetTasks        = false;
            currentNetworkConnectivityLevel = NetworkInformation.GetInternetConnectionProfile().GetNetworkConnectivityLevel();
            Window.Current.Activated       += Current_Activated;

            NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;

            string deviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily;

            if (deviceFamily.Contains("Mobile"))
            {
                device = Device.Mobile;
            }
            else if (deviceFamily.Contains("Desktop"))
            {
                device = Device.Desktop;
            }
            else
            {
                device = Device.Other;
            }

            mediaPlayer              = new MediaPlayer();
            mediaPlayer.MediaEnded  += MediaPlayer_MediaEnded;
            mediaPlayer.MediaFailed += MediaPlayer_MediaFailed;
            mediaPlayerElement.SetMediaPlayer(mediaPlayer);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
            httpClient           = new HttpClient();
            appleMovieDownloader = new AppleMovieDownloader(httpClient);
            sunrise          = DateTime.MinValue;
            sunset           = DateTime.MinValue;
            lastPositions    = new Queue <TimeSpan>();
            SpotifyHelper    = new SpotifyHelper();
            HueHelper        = new HueHelper();
            AirQualityHelper = new AirQualityHelper();
            CalendarHelper   = new CalendarHelper();

            rotationBuffer = 0;
            lightMode      = LightMode.Brightness;

            if (device == Device.Desktop)
            {
                dial = RadialController.CreateForCurrentView();
                dial.RotationResolutionInDegrees = 5;
                dial.UseAutomaticHapticFeedback  = false;
                dialConfig            = RadialControllerConfiguration.GetForCurrentView();
                menuItems             = new List <RadialControllerMenuItem>();
                isWindowFocused       = true;
                dial.ButtonClicked   += Dial_ButtonClicked;
                dial.RotationChanged += Dial_RotationChanged;
                dial.ControlAcquired += Dial_ControlAcquired;
                dial.ControlLost     += Dial_ControlLost;
            }
        }
Beispiel #3
0
 private async void AddRemoveSongButton_Click(object sender, RoutedEventArgs e)
 {
     if (SpotifyHelper.SavedTrack)
     {
         await SpotifyHelper.UnsaveCurrentTrack();
     }
     else
     {
         await SpotifyHelper.SaveCurrentTrack();
     }
 }
Beispiel #4
0
 private async void PlayPauseButton_Click(object sender, RoutedEventArgs e)
 {
     if (SpotifyHelper.IsPlaying)
     {
         await SpotifyHelper.Pause();
     }
     else
     {
         await SpotifyHelper.Play();
     }
 }
Beispiel #5
0
        /// <summary>
        /// Runs everything that is needed on app startup if there is internet access
        /// </summary>
        /// <returns></returns>
        private async Task RunOnLaunchInternetTasks()
        {
            if (currentNetworkConnectivityLevel == NetworkConnectivityLevel.InternetAccess && !ranOnLaunchInternetTasks)
            {
                await appleMovieDownloader.LoadMovies();

                PlayMovies();
                WebView.Visibility = Visibility.Visible;
                WebView.Navigate(new Uri(SpotifyHelper.GetAuthorizeUrl()));
                ranOnLaunchInternetTasks = true;
            }
        }
Beispiel #6
0
        private async void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            try
            {
                if (WebView.Source.Host.Contains("golf1052.com"))
                {
                    WebView.Visibility = Visibility.Collapsed;
                    await SpotifyHelper.ProcessRedirect(WebView.Source);

                    Task spotifyTokenRefresh = SpotifyHelper.CheckIfRefreshNeeded();
                    _ = SpotifyHelper.StartUpdate();
                }
            }
            catch
            {
                WebView.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #7
0
 private async void GoForwardButton_Click(object sender, RoutedEventArgs e)
 {
     await SpotifyHelper.GoFoward();
 }