Skip to content

Commit

Permalink
ffmpegがインストールされているか確認を促す通知を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Aug 8, 2023
1 parent b012b88 commit 8283871
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions src/Beutl.Extensions.FFmpeg/FFmpegPath.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<INotificationService>();
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()
Expand Down

0 comments on commit 8283871

Please sign in to comment.