diff --git a/src/Beutl.Extensions.FFmpeg/FFmpegPath.cs b/src/Beutl.Extensions.FFmpeg/FFmpegPath.cs index 5dc92fe24..4c4eee7b1 100644 --- a/src/Beutl.Extensions.FFmpeg/FFmpegPath.cs +++ b/src/Beutl.Extensions.FFmpeg/FFmpegPath.cs @@ -1,7 +1,11 @@ -using System.Reflection; +using System.Diagnostics; +using System.Reflection; + +using Beutl.Services; using FFmpeg.AutoGen; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; #if FFMPEG_BUILD_IN @@ -23,17 +27,41 @@ static FFmpegLoader() public static void Initialize() { - if (!_isInitialized) - throw new InvalidOperationException("Not initialized."); - - s_logger.LogInformation("avcodec_license() {License}", ffmpeg.avcodec_license()); - s_logger.LogInformation("avdevice_license() {License}", ffmpeg.avdevice_license()); - s_logger.LogInformation("avfilter_license() {License}", ffmpeg.avfilter_license()); - s_logger.LogInformation("avformat_license() {License}", ffmpeg.avformat_license()); - s_logger.LogInformation("avutil_license() {License}", ffmpeg.avutil_license()); - s_logger.LogInformation("postproc_license() {License}", ffmpeg.postproc_license()); - s_logger.LogInformation("swresample_license() {License}", ffmpeg.swresample_license()); - s_logger.LogInformation("swscale_license() {License}", ffmpeg.swscale_license()); + try + { + if (!_isInitialized) + throw new InvalidOperationException("Not initialized."); + + s_logger.LogInformation("avcodec_license() {License}", ffmpeg.avcodec_license()); + s_logger.LogInformation("avdevice_license() {License}", ffmpeg.avdevice_license()); + s_logger.LogInformation("avfilter_license() {License}", ffmpeg.avfilter_license()); + s_logger.LogInformation("avformat_license() {License}", ffmpeg.avformat_license()); + s_logger.LogInformation("avutil_license() {License}", ffmpeg.avutil_license()); + s_logger.LogInformation("postproc_license() {License}", ffmpeg.postproc_license()); + s_logger.LogInformation("swresample_license() {License}", ffmpeg.swresample_license()); + s_logger.LogInformation("swscale_license() {License}", ffmpeg.swscale_license()); + } + catch + { + INotificationService ns = ServiceLocator.Current.GetRequiredService(); + ns.Show(new Notification( + "FFmpeg error", + "FFmpegがインストールされているかを確認してください。", + NotificationType.Error, + OnActionButtonClick: OpenDocumentUrl, + ActionButtonText: "ドキュメントを開く")); + + throw; + } + } + + private static void OpenDocumentUrl() + { + Process.Start(new ProcessStartInfo("https://github.com/b-editor/beutl-docs/blob/main/ja/ffmpeg-install.md") + { + UseShellExecute = true, + Verb = "open" + }); } public static string GetExecutable()