Esempio n. 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Application.Current.MainWindow         = new MainWindow();
            Application.Current.MainWindow.Loaded += (snd, eva) => ViewModel.OnApplicationLoaded();
            Application.Current.MainWindow.Show();

            // Preload FFmpeg libraries in the background. This is optional.
            // FFmpeg will be automatically loaded if not already loaded when you try to open
            // a new stream or file. See issue #242
            ThreadPool.QueueUserWorkItem((s) =>
            {
                try
                {
                    // Force loading
                    MediaElement.LoadFFmpeg();
                }
                catch (Exception ex)
                {
                    GuiContext.Current?.EnqueueInvoke(() =>
                    {
                        MessageBox.Show(MainWindow,
                                        $"Unable to Load FFmpeg Libraries from path:\r\n    {MediaElement.FFmpegDirectory}" +
                                        $"\r\n{ex.GetType().Name}: {ex.Message}\r\n\r\nApplication will exit.",
                                        "FFmpeg Error",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);

                        Application.Current?.Shutdown();
                    });
                }
            });
        }
Esempio n. 2
0
        /// <inheritdoc />
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Current.MainWindow         = new MainWindow();
            Current.MainWindow.Loaded += (snd, eva) => ViewModel.OnApplicationLoaded();
            Current.MainWindow.Show();

            // Pre-load FFmpeg libraries in the background. This is optional.
            // FFmpeg will be automatically loaded if not already loaded when you try to open
            // a new stream or file. See issue #242
            ThreadPool.QueueUserWorkItem(s =>
            {
                try
                {
                    // Force loading
                    MediaElement.LoadFFmpeg();
                }
                catch (Exception ex)
                {
                    GuiContext.Current?.EnqueueInvoke(() =>
                    {
                        MessageBox.Show(MainWindow,
                                        $"Unable to Load FFmpeg Libraries from path:\r\n    {MediaElement.FFmpegDirectory}" +
                                        $"\r\nMake sure the above folder contains FFmpeg shared binaries (dll files) for the " +
                                        $"applicantion's architecture ({(Environment.Is64BitProcess ? "64-bit" : "32-bit")})" +
                                        $"\r\nTIP: You can download builds from https://ffmpeg.zeranoe.com/builds/" +
                                        $"\r\n{ex.GetType().Name}: {ex.Message}\r\n\r\nApplication will exit.",
                                        "FFmpeg Error",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);

                        Current?.Shutdown();
                    });
                }
            });
        }