Пример #1
0
        /// <summary>
        /// Adds the video details as a new 'Additional App' to the given game.
        /// </summary>
        /// <param name="game">The game entry.</param>
        /// <returns>The Additional App entry.</returns>
        public IAdditionalApplication AddVideoToGame(IGame game)
        {
            var app = game.AddNewAdditionalApplication();

            app.Name            = TitleWithPrefix;
            app.ApplicationPath = VlcUtilities.GetVlcExecutablePath();
            app.CommandLine     = GetVlcCmdArguments();
            return(app);
        }
Пример #2
0
        /// <summary>
        /// Verifies if an 'additional app' is properly set up with all the expected arguments.
        /// </summary>
        /// <param name="app">The Additional App entry.</param>
        public static bool IsAppCorrectlySetup(IAdditionalApplication app)
        {
            if (app.ApplicationPath != VlcUtilities.GetVlcExecutablePath())
            {
                return(false);
            }

            // Checking if the app's command line string is missing any of the VLC arguments expected by our plugin
            foreach (var expectedArg in _commonVlcArguments)
            {
                if (!app.CommandLine.Contains(expectedArg))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        public void CanImportAndExportAppDetails()
        {
            var additionalAppDummy = new AdditionalApplicationMock
            {
                ApplicationPath = VlcUtilities.GetVlcExecutablePath(),
                Name            = "Video: Presentation",
                CommandLine     = "-f --start-time=337 --stop-time=387 https://youtu.be/q_7KUC6CY6Q"
            };

            var gameMock = Substitute.For <IGame>();

            gameMock.AddNewAdditionalApplication().Returns(new AdditionalApplicationMock());

            var video = new GameVideo(additionalAppDummy);

            var exportedApp = video.AddVideoToGame(gameMock);

            Assert.Equal(additionalAppDummy.ApplicationPath, exportedApp.ApplicationPath);
            Assert.Equal(additionalAppDummy.Name, exportedApp.Name);
            Assert.Equal("-f --play-and-exit --start-time=337 --stop-time=387 https://youtu.be/q_7KUC6CY6Q",
                         exportedApp.CommandLine);
        }
Пример #4
0
        public void OnEventRaised(string eventType)
        {
            // On startup, we want to check if Launchbox's VLC distribution has the latest YouTube addon.
            if (eventType == SystemEventTypes.LaunchBoxStartupCompleted ||
                eventType == SystemEventTypes.BigBoxStartupCompleted)
            {
                VlcUtilities.VerifyYoutubeAddon();
            }
            else if (eventType == SystemEventTypes.SelectionChanged)
            {
                // When a game is selected, I want to check that the additional apps
                // for launching our videos are set up correctly.
                // This ensures that video link apps are always up to date with
                // the latest VLC path and command-line arguments.
                var selectedGames = PluginHelper.StateManager.GetAllSelectedGames();
                if (selectedGames.Length == 1)
                {
                    var game          = selectedGames[0];
                    var videoLinkApps = game.GetAllAdditionalApplications()
                                        .Where(x => x.Name.StartsWith(GameVideo.TitlePrefix))
                                        .ToList();

                    if (videoLinkApps.Count != 0)
                    {
                        foreach (var app in videoLinkApps)
                        {
                            if (!GameVideo.IsAppCorrectlySetup(app))
                            {
                                var gameVideo = new GameVideo(app);
                                gameVideo.UpdateExistingApp(app);
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
 /// <summary>
 /// This method updates an existing Additional App with the current video details.
 /// </summary>
 /// <param name="additionalApplication"></param>
 public void UpdateExistingApp(IAdditionalApplication additionalApplication)
 {
     additionalApplication.Name            = TitleWithPrefix;
     additionalApplication.ApplicationPath = VlcUtilities.GetVlcExecutablePath();
     additionalApplication.CommandLine     = GetVlcCmdArguments();
 }