Exemple #1
0
        public static async void StatusReportReceived(NowPlayingData data, WebViewController controller)
        {
            if (!data.IsPlaying)
            {
                return;
            }

            logger.Trace(data.ElapsedTime.ToString());

            try
            {
                if (data.ElapsedTime == lastElapsed)
                {
                    sameElapsedCounter++;

                    if (sameElapsedCounter > AppConstants.Instance.StuckDetectSameElapsedCount)
                    {
                        if (stuckResolveTryCount >= AppConstants.Instance.MaxStuckResolveTryCount)
                        {
                            logger.Warn("MaxStuckResolveTryCount exceeded.");

                            if (stuckResolveTryCount == AppConstants.Instance.MaxStuckResolveTryCount)
                            {
                                LogPlaybackStuck("MaxStuckResolveTryCountExceeded");
                            }

                            // TODO: Probably reload the page?
                        }

                        if (data.ElapsedTime == 0)
                        {
                            await PlayStartStuckResolve(controller);
                        }
                        else
                        {
                            await PlayMiddleStuckResolve(controller);
                        }

                        stuckResolveTryCount++;
                        sameElapsedCounter = -1 * AppConstants.Instance.StuckDetectSameElapsedExtraCount;
                    }
                }
                else
                {
                    stuckResolveTryCount = 0;
                    sameElapsedCounter   = 0;
                    lastElapsed          = data.ElapsedTime;
                }
            }
            catch (Exception ex)
            {
                logger.Warn("StuckResolveHelper.StatusReportReceived failed: " + ex.ToString());
            }
        }
Exemple #2
0
        private static async Task PlayStartStuckResolve(WebViewController controller)
        {
            bool apiFixSuccess = false;

            var player = new Player();

            apiFixSuccess = await player.PreviousTrack();

            if (apiFixSuccess)
            {
                LogPlaybackStuck("11");
            }
            else
            {
                await controller.TryResolvePlaybackStartStuck();

                LogPlaybackStuck("12");
            }
        }
Exemple #3
0
        private static async Task PlayMiddleStuckResolve(WebViewController controller)
        {
            await controller.TryResolvePlaybackMiddleStuck();

            LogPlaybackStuck("14");
        }
        public static async Task <KeyDownProcessResult> KeyDown(VirtualKey key, bool shiftPressed, bool ctrlPressed, bool altPressed, WebViewController controller, Controls.NowPlayingView nowPlaying)
        {
            if (key == VirtualKey.Space)
            {
                // Play/Pause
                await controller.PlayPause();
            }
            else if (key == VirtualKey.Right && ctrlPressed)
            {
                // Next Track
                await controller.NextTrack();

                if (nowPlaying.IsOpen)
                {
                    nowPlaying.PlayChangeTrackAnimation(reverse: false);
                }
            }
            else if (key == VirtualKey.Left && ctrlPressed)
            {
                // Prev Track
                await controller.PreviousTrack();

                if (nowPlaying.IsOpen)
                {
                    nowPlaying.PlayChangeTrackAnimation(reverse: true);
                }
            }
            else if (key == VirtualKey.Up && ctrlPressed & shiftPressed)
            {
                // Max volume
                await controller.SeekVolume(1.0);
            }
            else if (key == VirtualKey.Down && ctrlPressed && shiftPressed)
            {
                // Mute
                await controller.SeekVolume(0.0);
            }
            else if (key == VirtualKey.Up && ctrlPressed)
            {
                // Volume up
                var newVolume = Math.Min(PlayStatusTracker.LastPlayStatus.Volume + 0.1, 1.0);
                await controller.SeekVolume(newVolume);

                PlayStatusTracker.LastPlayStatus.Volume = newVolume;
            }
            else if (key == VirtualKey.Down && ctrlPressed)
            {
                // Volume down
                var newVolume = Math.Max(PlayStatusTracker.LastPlayStatus.Volume - 0.1, 0.0);
                await controller.SeekVolume(newVolume);

                PlayStatusTracker.LastPlayStatus.Volume = newVolume;
            }
            else if (key == VirtualKey.Left && altPressed)
            {
                // Back
                return(KeyDownProcessResult.GoBack);
            }
            else if (key == VirtualKey.Escape)
            {
                // Back
                return(KeyDownProcessResult.GoBack);
            }
            else if (key == VirtualKey.M && ctrlPressed && nowPlaying.IsOpen && nowPlaying.ViewMode == Controls.NowPlayingView.NowPlayingViewMode.Normal)
            {
                await nowPlaying.SwitchToMiniView();
            }
            else if (key == VirtualKey.Left || key == VirtualKey.Right || key == VirtualKey.Up || key == VirtualKey.Down)
            {
                // Do nothing, but don't switch out of now playing either.
            }
            else
            {
                return(KeyDownProcessResult.AskJs);
            }
            return(KeyDownProcessResult.Handled);
        }
Exemple #5
0
 public static void SetController(WebViewController controller)
 {
     _controller = controller;
 }