private async void WebViewCheckTimer_Tick(object sender, object e) { // Ignore if not logged in if (!TokenHelper.HasTokens()) { return; } try { var currentPlaying = await WebViewHelper.GetCurrentPlaying(); if (currentPlaying != prevCurrentPlaying) { prevCurrentPlaying = currentPlaying; logger.Info($"CurrentPlaying text extracted from web page changed to '{currentPlaying}'."); await PlayStatusTracker.RefreshPlayStatus(); } } catch (Exception ex) { logger.Warn("checkCurrentPlaying failed: " + ex.ToString()); } try { webViewBackEnabled = await WebViewHelper.IsBackPossible(); } catch (Exception ex) { logger.Warn("checkBackButtonEnable failed: " + ex.ToString()); } }
private async void NextTrackButton_Tapped(object sender, TappedRoutedEventArgs e) { try { HideToLeftAnimation(); if (!(await PlaybackActionHelper.NextTrack())) { showFromLeftStoryboard.Begin(); animationState = AnimationState.None; ViewModel.ProgressRingActive = false; return; } ViewModel.NextButtonEnabled = false; await Task.Delay(1000); await PlayStatusTracker.RefreshPlayStatus(); ViewModel.NextButtonEnabled = true; } catch (UnauthorizedAccessException) { UnauthorizedHelper.OnUnauthorizedError(); } }
private async void SeekVolume(double percentage) { try { PlayStatusTracker.SeekVolume(percentage); await xpoWebView.Controller.SeekVolume(percentage); } catch (Exception ex) { logger.Warn("SeekVolume failed: " + ex.ToString()); } }
private async void UserControl_Loaded(object sender, RoutedEventArgs e) { try { await Update(); await PlayStatusTracker.RefreshPlayStatus(); } catch (Exception ex) { logger.Warn("Loaded event failed: " + ex.ToString()); } }
private async void PlayButton_Tapped(object sender, TappedRoutedEventArgs e) { try { ViewModel.IsPlaying = true; ViewModel.PlayPauseButtonEnabled = false; timer.Stop(); // This delay is a workaround for PlayPauseButtonEnabled to // update the newly appeared UI. Otherwize it appears after // running PlaybackActionHelper.Play(). await Task.Delay(100); if (await PlaybackActionHelper.Play()) { await Task.Delay(1000); await PlayStatusTracker.RefreshPlayStatus(); ViewModel.PlayPauseButtonEnabled = true; } else { ViewModel.IsPlaying = false; ViewModel.PlayPauseButtonEnabled = true; await PlayStatusTracker.RefreshPlayStatus(); } } catch (UnauthorizedAccessException) { UnauthorizedHelper.OnUnauthorizedError(); } finally { ViewModel.PlayPauseButtonEnabled = true; if (!timer.IsEnabled) { timer.Start(); } } }
// Use this for initialization void Awake() { controller = GameObject.FindGameObjectWithTag("Controller"); if (controller != null) { cursorHandler = controller.GetComponent <CursorHandler>(); } player = GameObject.FindGameObjectWithTag("Player"); if (player != null) { playerMovements = player.GetComponent <PlayerMovements>(); } magicLanternLogicOBJ = GameObject.FindGameObjectWithTag("MagicLanternLogic"); if (magicLanternLogicOBJ != null) { magicLanternLogic = magicLanternLogicOBJ.GetComponent <MagicLantern>(); magicLanternGraphic = magicLanternLogicOBJ.GetComponent <GraphicLantern>(); glassesManager = magicLanternLogicOBJ.GetComponent <GlassesManager>(); } magicLantern = GameObject.FindGameObjectWithTag("Lantern"); canvasPlayingUI = GameObject.FindGameObjectWithTag("CanvasPlayingUI"); if (canvasPlayingUI != null) { playingUI = canvasPlayingUI.GetComponent <PlayingUI>(); playingUILateral = canvasPlayingUI.GetComponent <PlayingUILateral>(); playingUIGameOver = canvasPlayingUI.GetComponent <PlayingUIGameOver>(); } canvasMenu = UtilFinder._FindGameObjectByTag("CanvasMenu"); unlockableContentUI = UtilFinder._GetComponentOfGameObjectWithTag <UnlockableContentUI> ("Controller"); informativeManager = UtilFinder._GetComponentOfGameObjectWithTag <InformativeManager> ("MenuController"); menuManager = UtilFinder._GetComponentOfGameObjectWithTag <MenuManager> ("MenuController"); playStatusTracker = UtilFinder._GetComponentOfGameObjectWithTag <PlayStatusTracker> ("Controller"); testInformativeManager = UtilFinder._GetComponentOfGameObjectWithTag <TestInformativeManager> ("TestController"); testingController = GameObject.FindGameObjectWithTag("TestController"); if (testingController != null) { hintAnalyzer = testingController.GetComponent <HintAnalyzer>(); } hubController = GameObject.FindGameObjectWithTag("HubController"); if (hubController != null) { unlockedLevelControl = hubController.GetComponent <UnlockedLevelControl>(); hubLadderControl = hubController.GetComponent <HubLadderControl>(); hubLanternControl = hubController.GetComponent <HubLanternControl>(); } if (controller != null) { inputKeeper = controller.GetComponent <InputKeeper>(); } camera = Camera.main.gameObject; if (camera != null) { cameraMovements = camera.GetComponent <CameraMovements>(); cameraHandler = camera.GetComponent <CameraHandler>(); } GameObject levelChanger = GameObject.FindGameObjectWithTag("CanvasLoadLevel"); if (levelChanger != null) { levelChangerGeneral = levelChanger.GetComponent <LevelChangerGeneral> (); } GameObject buttonControllerOBJ = GameObject.FindGameObjectWithTag("ButtonControllerLink"); if (buttonControllerOBJ != null) { buttonController = buttonControllerOBJ.GetComponent <ButtonController> (); inputManager = buttonControllerOBJ.GetComponent <InputManager>(); buttonKeyboardMouse = buttonControllerOBJ.GetComponent <ButtonKeyboardMouse>(); } }
private async void SystemControls_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs e) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { var mediaControls = SystemMediaTransportControls.GetForCurrentView(); try { switch (e.Button) { case SystemMediaTransportControlsButton.Play: if (await PlaybackActionHelper.Play()) { mediaControls.PlaybackStatus = MediaPlaybackStatus.Playing; } break; case SystemMediaTransportControlsButton.Pause: if (await PlaybackActionHelper.Pause()) { mediaControls.PlaybackStatus = MediaPlaybackStatus.Paused; } break; case SystemMediaTransportControlsButton.Stop: if (await PlaybackActionHelper.Pause()) { mediaControls.PlaybackStatus = MediaPlaybackStatus.Paused; } break; case SystemMediaTransportControlsButton.Next: if (await PlaybackActionHelper.NextTrack()) { compactOverlayView?.PlayChangeTrackAnimation(reverse: false); } break; case SystemMediaTransportControlsButton.Previous: if (await PlaybackActionHelper.PreviousTrack()) { compactOverlayView?.PlayChangeTrackAnimation(reverse: true); } // Necessary for progress bar update, in case 'previous' command goes to // the beginning of the same track. await Task.Delay(500); await PlayStatusTracker.RefreshPlayStatus(); break; } } catch (UnauthorizedAccessException) { UnauthorizedHelper.OnUnauthorizedError(); } }); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { InitTitleBar(); ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize); Window.Current.CoreWindow.Activated += Window_Activated; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; // Update app constants from server AppConstants.Update(); // Update assets from server AssetManager.UpdateAssets(); // Play silent sound to avoid suspending the app when it's minimized. silentMediaPlayer.Play(); // Media controls are necessary for the audio to continue when app is minimized. var mediaControls = SystemMediaTransportControls.GetForCurrentView(); mediaControls.IsEnabled = true; mediaControls.IsPreviousEnabled = true; mediaControls.IsNextEnabled = true; mediaControls.IsPlayEnabled = true; mediaControls.IsPauseEnabled = true; mediaControls.PlaybackStatus = MediaPlaybackStatus.Paused; mediaControls.ButtonPressed += SystemControls_ButtonPressed; await mediaControls.DisplayUpdater.CopyFromFileAsync(MediaPlaybackType.Music, await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Media/silent.wav"))); PlayStatusTracker.MediaControls = mediaControls; PlayStatusTracker.StartRegularRefresh(); // Show what's new if necessary if (WhatsNewHelper.ShouldShowWhatsNew()) { shouldShowWhatsNew = true; } webViewCheckTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1), }; webViewCheckTimer.Tick += WebViewCheckTimer_Tick; webViewCheckTimer.Start(); clipboardCheckTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(3), }; clipboardCheckTimer.Tick += ClipboardCheckTimer_Tick; clipboardCheckTimer.Start(); stuckDetectTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(4), }; stuckDetectTimer.Tick += StuckDetectTimer_Tick; stuckDetectTimer.Start(); AnalyticsHelper.PageView("MainPage"); AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString()); if (ThemeHelper.GetCurrentTheme() == Theme.Light) { splashScreenToLightStoryboard.Begin(); } developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage(); LyricsViewerIntegrationHelper.InitIntegration(); LiveTileHelper.InitLiveTileUpdates(); JumpListHelper.DeleteRecentJumplistEntries(); }
private async void RefreshPlayStatus() { await Task.Delay(1000); await PlayStatusTracker.RefreshPlayStatus(); }
private static async void SystemControls_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs e) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var mediaControls = SystemMediaTransportControls.GetForCurrentView(); try { switch (e.Button) { case SystemMediaTransportControlsButton.Play: if (await PlaybackActionHelper.Play()) { mediaControls.PlaybackStatus = MediaPlaybackStatus.Playing; } break; case SystemMediaTransportControlsButton.Pause: if (await PlaybackActionHelper.Pause()) { mediaControls.PlaybackStatus = MediaPlaybackStatus.Paused; } break; case SystemMediaTransportControlsButton.Stop: if (await PlaybackActionHelper.Pause()) { mediaControls.PlaybackStatus = MediaPlaybackStatus.Paused; } break; case SystemMediaTransportControlsButton.Next: if (await PlaybackActionHelper.NextTrack()) { TrackChanged?.Invoke(null, new TrackChangedEventArgs { Direction = TrackChangedEventArgs.TrackChangeDirection.Forward, }); } break; case SystemMediaTransportControlsButton.Previous: if (await PlaybackActionHelper.PreviousTrack()) { TrackChanged?.Invoke(null, new TrackChangedEventArgs { Direction = TrackChangedEventArgs.TrackChangeDirection.Backward, }); } // Necessary for progress bar update, in case 'previous' command goes to // the beginning of the same track. await Task.Delay(500); await PlayStatusTracker.RefreshPlayStatus(); break; } } catch (UnauthorizedAccessException) { UnauthorizedHelper.OnUnauthorizedError(); } }); }