private void CreateSplashVideoWindow(bool skipSplashImage)
        {
            var content = new SplashScreenVideo(videoPath);
            var window  = new Window
            {
                WindowStyle = WindowStyle.None,
                ResizeMode  = ResizeMode.NoResize,
                WindowState = WindowState.Maximized,
                Title       = "PlayniteSplashScreenExtensionVideo",
                Content     = content
            };

            content.VideoPlayer.MediaEnded += async(src, args) =>
            {
                content.VideoPlayer.Source = null;
                if (!skipSplashImage)
                {
                    CreateSplashImageWindow();
                    await Task.Delay(3000);
                }
                window.Close();
                return;
            };

            // Using ShowDialog method makes the window lock Playnite main window
            // This ensures that the whole video is played before game is launched
            window.ShowDialog();
        }
        private void CreateSplashVideoWindow(bool showSplashImage, string videoPath, string splashImagePath, string logoPath)
        {
            // Mutes Playnite Background music to make sure its not playing when video or splash screen image
            // is active and prevents music not stopping when game is already running
            MuteBackgroundMusic();

            // This will tell them main (Playnite) thread when to continue later
            var stopBlockingEvent = new AutoResetEvent(false);

            // This creates new UI thread for splash window.
            // This way we can do any UI things we want with our window without affecting Playnite's UI.
            var splashWindowThread = new Thread(new ThreadStart(() =>
            {
                var content         = new SplashScreenVideo(videoPath);
                currentSplashWindow = new Window
                {
                    WindowStyle           = WindowStyle.None,
                    ResizeMode            = ResizeMode.NoResize,
                    WindowState           = WindowState.Maximized,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                    Focusable             = false,
                    Content = content
                };

                currentSplashWindow.Closed += (_, __) =>
                {
                    // To prevent video sound from playing in case window was closed manually
                    content.VideoPlayer.Source = null;

                    // Apparently necessary to properly cleanup UI thread we created for this window.
                    currentSplashWindow.Dispatcher.InvokeShutdown();

                    // Unblock main thread and let Playnite start a game. Works if window is closed manually or by event
                    stopBlockingEvent?.Set();
                    currentSplashWindow = null;
                };

                content.VideoPlayer.MediaEnded += async(_, __) =>
                {
                    content.VideoPlayer.Source = null;
                    if (showSplashImage == true)
                    {
                        currentSplashWindow.Content = new SplashScreenImage(settings.Settings, splashImagePath, logoPath);
                        // This needs to run async otherwise we would block our UI thread and prevent splash image from showing
                        await Task.Delay(3000);

                        // Unblock main thread and let Playnite start a game.
                        stopBlockingEvent?.Set();

                        if ((PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Desktop && settings.Settings.CloseSplashScreenDesktopMode) ||
                            (PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Fullscreen && settings.Settings.CloseSplashScreenFullscreenMode))
                        {
                            // Closes splash screen after another 60 seconds, but the game is already starting.
                            await Task.Delay(60000);
                            currentSplashWindow?.Close();
                            currentSplashWindow = null;
                        }
                    }
                    else
                    {
                        // Unblock main thread and let Playnite start a game.
                        stopBlockingEvent?.Set();
                        currentSplashWindow?.Close();
                    }
                };

                currentSplashWindow.Show();
                Dispatcher.Run();
            }));

            splashWindowThread.SetApartmentState(ApartmentState.STA);
            splashWindowThread.IsBackground = true;
            splashWindowThread.Start();

            // Blocks execution until the event occurs from splash window
            stopBlockingEvent.WaitOne();
            stopBlockingEvent.Dispose();
            stopBlockingEvent = null;
        }