Exemplo n.º 1
0
        public OpenVideoResult Load(string filePath)
        {
            // Instanciate appropriate video reader class.
            string sequenceFilename = FilesystemHelper.GetSequenceFilename(filePath);

            if (!string.IsNullOrEmpty(sequenceFilename))
            {
                videoReader = VideoTypeManager.GetImageSequenceReader();
                filePath    = Path.Combine(Path.GetDirectoryName(filePath), sequenceFilename);
            }
            else
            {
                if (FilesystemHelper.IsReplayWatcher(filePath))
                {
                    // This happens when we first load a file watcher into this screen.
                    // Subsequent calls by the watcher will use the actual file name.
                    // For this initial step, run the most recent file of the directory, if any.
                    filePath = VideoTypeManager.GetMostRecentSupportedVideo(filePath);
                    if (string.IsNullOrEmpty(filePath))
                    {
                        // If the directory doesn't have any supported files yet it's not an error, we just load an empty player and get ready.
                        return(OpenVideoResult.EmptyWatcher);
                    }
                }

                videoReader = VideoTypeManager.GetVideoReader(Path.GetExtension(filePath));
            }

            if (videoReader != null)
            {
                videoReader.Options = new VideoOptions(PreferencesManager.PlayerPreferences.AspectRatio, ImageRotation.Rotate0, Demosaicing.None, PreferencesManager.PlayerPreferences.DeinterlaceByDefault);
                return(videoReader.Open(filePath));
            }
            else
            {
                return(OpenVideoResult.NotSupported);
            }
        }
Exemplo n.º 2
0
        private static void LoadInSpecificTarget(ScreenManagerKernel manager, int targetScreen, string path, ScreenDescriptionPlayback screenDescription)
        {
            AbstractScreen screen = manager.GetScreenAt(targetScreen);

            if (screen is CaptureScreen)
            {
                // Loading a video onto a capture screen should not close the capture screen.
                // If there is room to add a second screen, we add a playback screen and load the video there, otherwise, we don't do anything.
                if (manager.ScreenCount == 1)
                {
                    manager.AddPlayerScreen();
                    LoadInSpecificTarget(manager, 1, path, screenDescription);
                }
            }
            else if (screen is PlayerScreen)
            {
                PlayerScreen playerScreen = screen as PlayerScreen;

                if (playerScreen.IsWaitingForIdle)
                {
                    // The player screen will yield its thread after having loaded the first frame and come back later.
                    // We must not launch a new video while it's waiting.
                    log.ErrorFormat("Player screen is currently busy loading the previous video. Aborting load.");
                    return;
                }

                bool confirmed = manager.BeforeReplacingPlayerContent(targetScreen);
                if (!confirmed)
                {
                    return;
                }

                LoadVideo(playerScreen, path, screenDescription);

                bool prefsNeedSaving = false;
                if (screenDescription != null && screenDescription.IsReplayWatcher)
                {
                    PreferencesManager.FileExplorerPreferences.AddRecentWatcher(path);
                    PreferencesManager.FileExplorerPreferences.LastReplayFolder = path;
                    prefsNeedSaving = true;
                }

                if (playerScreen.FrameServer.Loaded)
                {
                    NotificationCenter.RaiseFileOpened(null, path);

                    if (screenDescription != null && screenDescription.IsReplayWatcher)
                    {
                        // At this point we have lost the actual file that was loaded. The path here still contaiins the special '*' to indicate the watched folder.
                        // The actual file is the latest file in the folder this was computed right before loading.
                        string actualPath = VideoTypeManager.GetMostRecentSupportedVideo(path);
                        PreferencesManager.FileExplorerPreferences.AddRecentFile(actualPath);
                    }
                    else
                    {
                        PreferencesManager.FileExplorerPreferences.AddRecentFile(path);
                    }

                    prefsNeedSaving = true;
                }

                if (prefsNeedSaving)
                {
                    PreferencesManager.Save();
                }

                manager.OrganizeScreens();
                manager.OrganizeCommonControls();
                manager.OrganizeMenus();
                manager.UpdateStatusBar();
            }
        }