Exemple #1
0
        private void GlobalKeyUpHandler(CoreWindow sender, KeyEventArgs args)
        {
            if (Visibility != Visibility.Visible)
            {
                return;
            }

            if (args.VirtualKey == VirtualKey.Space)
            {
                switch (OnlinePlayer.MediaPlayer.PlaybackSession.PlaybackState)
                {
                case MediaPlaybackState.Playing:
                    OnlinePlayer.MediaPlayer.Pause();
                    break;

                case MediaPlaybackState.Paused:
                    OnlinePlayer.MediaPlayer.Play();
                    break;
                }
            }
            if (args.VirtualKey == VirtualKey.PageUp)
            {
                m_ViewModel.NextTrackCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.PageDown)
            {
                m_ViewModel.PreviousTrackCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.P)
            {
                if (m_ViewModel.IsCompactOverlayEnabled)
                {
                    m_ViewModel.LeaveCompactModeCommand.Execute(null);
                }
                else
                {
                    m_ViewModel.EnableCompactModeCommand.Execute(null);
                }
            }
            if (m_ViewModel.IsCompactOverlayEnabled)
            {
                return;
            }

            if (args.VirtualKey == VirtualKey.Escape)
            {
                var view = ApplicationView.GetForCurrentView();
                if (view.IsFullScreenMode)
                {
                    view.ExitFullScreenMode();
                }
                else
                {
                    m_ViewModel.ChangePage("Releases", null);
                }
            }
            if (args.VirtualKey == VirtualKey.F11 || args.VirtualKey == VirtualKey.F)
            {
                m_ViewModel.ToggleFullScreenCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.Up)
            {
                m_ViewModel.ChangeVolumeCommand.Execute(.05);
            }
            if (args.VirtualKey == VirtualKey.Down)
            {
                m_ViewModel.ChangeVolumeCommand.Execute(-.05);
            }
            if (args.VirtualKey == VirtualKey.M)
            {
                OnlinePlayer.MediaPlayer.IsMuted = !OnlinePlayer.MediaPlayer.IsMuted;
            }
            if (args.VirtualKey == VirtualKey.Home)
            {
                m_ViewModel.ShowPlaylistCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.End)
            {
                m_ViewModel.ShowPlaylistButton = true;
            }
            if (args.VirtualKey == VirtualKey.Left)
            {
                var minutes  = m_ViewModel.JumpMinutes;
                var seconds  = m_ViewModel.JumpSeconds;
                var timeSpan = new TimeSpan(0, minutes, seconds);
                var position = OnlinePlayer.MediaPlayer.PlaybackSession.Position;
                if (position > timeSpan)
                {
                    OnlinePlayer.MediaPlayer.PlaybackSession.Position -= timeSpan;
                }
            }
            if (args.VirtualKey == VirtualKey.Right)
            {
                var minutes  = m_ViewModel.JumpMinutes;
                var seconds  = m_ViewModel.JumpSeconds;
                var timeSpan = new TimeSpan(0, minutes, seconds);
                var position = OnlinePlayer.MediaPlayer.PlaybackSession.Position;
                var duration = OnlinePlayer.MediaPlayer.PlaybackSession.NaturalDuration;
                if (duration - position > timeSpan)
                {
                    OnlinePlayer.MediaPlayer.PlaybackSession.Position += timeSpan;
                }
            }
        }
Exemple #2
0
        private void GlobalKeyUpHandler(CoreWindow sender, KeyEventArgs args)
        {
            if (Visibility != Visibility.Visible)
            {
                return;
            }

            if (args.VirtualKey == VirtualKey.Space)
            {
                switch (OnlinePlayer.MediaPlayer.PlaybackSession.PlaybackState)
                {
                case MediaPlaybackState.Playing:
                    OnlinePlayer.MediaPlayer.Pause();
                    break;

                case MediaPlaybackState.Paused:
                    OnlinePlayer.MediaPlayer.Play();
                    break;
                }
            }
            if (args.VirtualKey == VirtualKey.PageUp)
            {
                m_ViewModel.NextTrackCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.PageDown)
            {
                m_ViewModel.PreviousTrackCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.P)
            {
                if (m_ViewModel.IsCompactOverlayEnabled)
                {
                    m_ViewModel.LeaveCompactModeCommand.Execute(null);
                }
                else
                {
                    m_ViewModel.EnableCompactModeCommand.Execute(null);
                }
            }
            if (m_ViewModel.IsCompactOverlayEnabled)
            {
                return;
            }

            if (args.VirtualKey == VirtualKey.Escape)
            {
                var view = ApplicationView.GetForCurrentView();
                if (view.IsFullScreenMode)
                {
                    view.ExitFullScreenMode();
                }
                else
                {
                    m_ViewModel.ChangePage("Releases", null);
                }
            }
            if (args.VirtualKey == VirtualKey.F11 || args.VirtualKey == VirtualKey.F)
            {
                m_ViewModel.ToggleFullScreenCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.Up)
            {
                m_ViewModel.ChangeVolumeCommand.Execute(.05);
            }
            if (args.VirtualKey == VirtualKey.Down)
            {
                m_ViewModel.ChangeVolumeCommand.Execute(-.05);
            }
            if (args.VirtualKey == VirtualKey.M)
            {
                OnlinePlayer.MediaPlayer.IsMuted = !OnlinePlayer.MediaPlayer.IsMuted;
            }
            if (args.VirtualKey == VirtualKey.Home)
            {
                m_ViewModel.ShowPlaylistCommand.Execute(null);
            }
            if (args.VirtualKey == VirtualKey.End)
            {
                m_ViewModel.ShowPlaylistButton = true;
            }

            var element = FocusManager.GetFocusedElement();
            var slider  = element as Slider;

            var isVolumeSlider = slider != null && slider.Name == "VolumeSlider";

            if (isVolumeSlider)
            {
                return;
            }

            if (args.VirtualKey == VirtualKey.Left)
            {
                PerformLeftJump();
            }
            if (args.VirtualKey == VirtualKey.Right)
            {
                PerformRightJump();
            }
        }