diff --git a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfmpegAudioSupportProvider.cs b/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfmpegAudioSupportProvider.cs deleted file mode 100644 index 2ae825c81..000000000 --- a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfmpegAudioSupportProvider.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.IO; -using FfmpegUnity; -using UniInject; -using UniRx; -using UnityEngine; - -public class FfmpegAudioSupportProvider : AbstractAudioSupportProvider -{ - [InjectedInInspector] - public FfplayCommand ffplayCommandPrefab; - - private FfplayCommand ffplayCommand; - private FfmpegPlayerVideoTexture ffmpegPlayerVideoTexture; - - private RenderTexture ffmpegRenderTexture; - public RenderTexture FfmpegRenderTexture - { - get => ffmpegRenderTexture; - set - { - ffmpegRenderTexture = value; - if (ffplayCommand != null - && ffplayCommand.VideoTexture != null) - { - ffplayCommand.VideoTexture.VideoTexture = ffmpegRenderTexture; - } - } - } - - public override IObservable LoadAsObservable(string audioUri, bool streamAudio, double startPositionInMillis) - { - DestroyFfmpegPlayer(); - - ffplayCommand = Instantiate(ffplayCommandPrefab, transform); - ffmpegPlayerVideoTexture = ffplayCommand.GetComponentInChildren(); - ffplayCommand.InputPath = audioUri; - if (FfmpegRenderTexture != null - && ffplayCommand.VideoTexture != null) - { - ffplayCommand.VideoTexture.VideoTexture = FfmpegRenderTexture; - } - - // Play to trigger loading - ffplayCommand.Play(); - PositionInMillis = startPositionInMillis; - - return Observable.Create(o => - { - StartCoroutine(CoroutineUtils.ExecuteWhenConditionIsTrue( - () => this == null || DurationInMillis > 0, - () => - { - if (this == null) - { - string errorMessage = $"Failed to load audio clip '{audioUri}': {nameof(FfmpegAudioSupportProvider)} has been destroyed already."; - Debug.LogError(errorMessage); - throw new AudioSupportProviderException(errorMessage); - } - - if (ffplayCommand == null) - { - o.OnError(new SongAudioPlayerException("Failed to load file with ffmpeg. FfplayCommand is null")); - return; - } - - if (IsPlaying) - { - ffplayCommand.TogglePause(); - } - o.OnNext(new AudioLoadedEvent(audioUri)); - })); - return Disposable.Empty; - }); - } - - public override bool IsSupported(string audioUri) - { - return !WebViewUtils.CanHandleWebViewUrl(audioUri) - && settings.FfmpegToPlayMediaFilesUsage is not EThirdPartyLibraryUsage.Never - && (ApplicationUtils.IsFfmpegSupportedAudioFormat(Path.GetExtension(audioUri)) - || ApplicationUtils.IsFfmpegSupportedVideoFormat(Path.GetExtension(audioUri))); - } - - public override void Unload() - { - DestroyFfmpegPlayer(); - } - - public override void Play() - { - if (ffplayCommand == null) - { - return; - } - - if (ffplayCommand.Paused) - { - ffplayCommand.TogglePause(); - } - } - - public override void Pause() - { - if (ffplayCommand == null) - { - return; - } - - if (ffplayCommand.IsRunning - && !ffplayCommand.Paused) - { - ffplayCommand.TogglePause(); - } - } - - public override void Stop() - { - if (ffplayCommand == null) - { - return; - } - - ffplayCommand.Stop(); - } - - public override bool IsPlaying - { - get => ffplayCommand != null && ffplayCommand.IsRunning && !ffplayCommand.Paused; - set - { - if (value) - { - Play(); - } - else - { - Pause(); - } - } - } - - public override double PlaybackSpeed - { - get => 1; - set => SetPlaybackSpeed(value, true); - } - - public override void SetPlaybackSpeed(double newValue, bool changeTempoButKeepPitch) - { - // Not supported - } - - public override double PositionInMillis - { - get => ffplayCommand.CurrentTime * 1000.0; - // TODO: SeekTime is inaccurate, notably in the song editor. - set => ffplayCommand.SeekTime(value / 1000.0); - } - - public override double DurationInMillis => ffplayCommand != null - ? ffplayCommand.Duration * 1000.0 - : 0; - - public override double VolumeFactor - { - get => ffplayCommand.AudioSourceComponent.volume; - set => ffplayCommand.AudioSourceComponent.volume = (float)value; - } - - private void DestroyFfmpegPlayer() - { - Destroy(FfmpegRenderTexture); - DestroyFfmpegCommand(); - } - - private void DestroyFfmpegCommand() - { - if (ffplayCommand == null) - { - return; - } - - if (ffplayCommand.AudioSourceComponent != null) - { - ffplayCommand.AudioSourceComponent.mute = true; - } - ffplayCommand.gameObject.SetActive(false); - if (Application.isEditor && !Application.isPlaying) - { - DestroyImmediate(ffplayCommand.gameObject); - } - else - { - Destroy(ffplayCommand.gameObject); - } - ffplayCommand = null; - } -} diff --git a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfmpegAudioSupportProvider.cs.meta b/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfmpegAudioSupportProvider.cs.meta deleted file mode 100644 index 5d8065356..000000000 --- a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfmpegAudioSupportProvider.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ab863f5f6cc548d8abbdf9854c44edd8 -timeCreated: 1715497947 \ No newline at end of file diff --git a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfplayAudioWithVolume.cs b/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfplayAudioWithVolume.cs deleted file mode 100644 index 3a4858aba..000000000 --- a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfplayAudioWithVolume.cs +++ /dev/null @@ -1,46 +0,0 @@ -using FfmpegUnity; -using UnityEngine; - -[RequireComponent(typeof(AudioSource))] -public class FfplayAudioWithVolume : FfplayAudio -{ - private AudioSource audioSource; - - private float volume = 1f; - - private void Awake() - { - audioSource = GetComponent(); - } - - private void Update() - { - volume = audioSource.volume * AudioListener.volume; - } - - protected override void OnAudioFilterRead(float[] data, int channels) - { - base.OnAudioFilterRead(data, channels); - - // Apply volume - if (volume >= 1) - { - return; - } - - if (volume <= 0) - { - for (int i = 0; i < data.Length; i++) - { - data[i] = 0; - } - } - else - { - for (int i = 0; i < data.Length; i++) - { - data[i] *= volume; - } - } - } -} diff --git a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfplayAudioWithVolume.cs.meta b/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfplayAudioWithVolume.cs.meta deleted file mode 100644 index bba0125e8..000000000 --- a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/FfplayAudioWithVolume.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d3ff5fb199814e7e83145d7718a53851 -timeCreated: 1689102918 \ No newline at end of file diff --git a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/SongAudioPlayer.cs b/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/SongAudioPlayer.cs index 1a602ec26..67d59b9c1 100644 --- a/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/SongAudioPlayer.cs +++ b/UltraStar Play/Assets/Common/Audio/SongAudioPlayer/SongAudioPlayer.cs @@ -195,22 +195,6 @@ public double PlaybackSpeed } } - public RenderTexture FfmpegRenderTexture { - get - { - return currentAudioSupportProvider is FfmpegAudioSupportProvider ffmpegAudioSupportProvider - ? ffmpegAudioSupportProvider.FfmpegRenderTexture - : null; - } - set - { - if (currentAudioSupportProvider is FfmpegAudioSupportProvider ffmpegAudioSupportProvider) - { - ffmpegAudioSupportProvider.FfmpegRenderTexture = value; - } - } - } - private float lastApplyPlaybackStateToAudioProviderTimeInSeconds; private void OnDestroy() diff --git a/UltraStar Play/Assets/Common/Scene/CommonSceneObjects.prefab b/UltraStar Play/Assets/Common/Scene/CommonSceneObjects.prefab index bfbd17b4e..b03e4815b 100644 --- a/UltraStar Play/Assets/Common/Scene/CommonSceneObjects.prefab +++ b/UltraStar Play/Assets/Common/Scene/CommonSceneObjects.prefab @@ -1004,7 +1004,6 @@ Transform: - {fileID: 1873797141292969039} - {fileID: 3570172285929320791} - {fileID: 8951246057956905287} - - {fileID: 1535503042610526989} - {fileID: 2311127367653777862} - {fileID: 7657069212502855339} m_Father: {fileID: 8069444317427349030} @@ -9598,50 +9597,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7858c3b3db034e2aa03cae273cc54e4c, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!1 &8022432702083802998 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1535503042610526989} - - component: {fileID: 702766123259852127} - m_Layer: 0 - m_Name: SongMediaFileConversionManager - m_TagString: MelodyManiaOnly - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1535503042610526989 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8022432702083802998} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 5483831765678408185} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &702766123259852127 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8022432702083802998} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 998caedc1a8d42fb86616e21b51a656a, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1 &8036134303383211572 GameObject: m_ObjectHideFlags: 0 diff --git a/UltraStar Play/Assets/Common/Scene/CommonSceneObjectsBinder.cs b/UltraStar Play/Assets/Common/Scene/CommonSceneObjectsBinder.cs index b6132fc3d..3cf32e87f 100644 --- a/UltraStar Play/Assets/Common/Scene/CommonSceneObjectsBinder.cs +++ b/UltraStar Play/Assets/Common/Scene/CommonSceneObjectsBinder.cs @@ -44,7 +44,6 @@ public List GetBindings() bb.BindExistingInstance(MicSampleRecorderManager.Instance); bb.BindExistingInstance(AchievementEventStream.Instance); bb.BindExistingInstance(WebViewManager.Instance); - bb.BindExistingInstance(SongMediaFileConversionManager.Instance); bb.BindExistingInstance(ModManager.Instance); bb.BindExistingInstance(RuntimeUiInspectionManager.Instance); bb.BindExistingInstance(VlcManager.Instance); diff --git a/UltraStar Play/Assets/Common/SongMediaFileConversion.meta b/UltraStar Play/Assets/Common/SongMediaFileConversion.meta deleted file mode 100644 index 0a42c4a0c..000000000 --- a/UltraStar Play/Assets/Common/SongMediaFileConversion.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: df3d0a236458428fa4ab7932a132e4ba -timeCreated: 1689351017 \ No newline at end of file diff --git a/UltraStar Play/Assets/Common/SongMediaFileConversion/SongMediaFileConversionManager.cs b/UltraStar Play/Assets/Common/SongMediaFileConversion/SongMediaFileConversionManager.cs deleted file mode 100644 index b5d8af4e2..000000000 --- a/UltraStar Play/Assets/Common/SongMediaFileConversion/SongMediaFileConversionManager.cs +++ /dev/null @@ -1,443 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading; -using FfmpegUnity; -using UniInject; -using UnityEngine; - -// Disable warning about fields that are never assigned, their values are injected. -#pragma warning disable CS0649 - -public class SongMediaFileConversionManager : AbstractSingletonBehaviour, INeedInjection -{ - public static SongMediaFileConversionManager Instance => DontDestroyOnLoadManager.Instance.FindComponentOrThrow(); - - [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] - static void StaticInit() - { - MinTargetFileSizeInBytes = DefaultMinTargetFileSizeInBytes; - } - - private const int DefaultMinTargetFileSizeInBytes = 100 * 1024; // 100 KB - private const int MaxConversionRetry = 3; - - [Inject] - private JobManager jobManager; - - [Inject] - private Settings settings; - - [Inject] - private SongMetaManager songMetaManager; - - private readonly List runningSongMediaConversionCoroutines = new(); - private readonly List pendingSongMediaConversionCoroutines = new(); - - public static int MinTargetFileSizeInBytes { get; set; } = DefaultMinTargetFileSizeInBytes; - - protected override object GetInstance() - { - return Instance; - } - - private void Update() - { - if (pendingSongMediaConversionCoroutines.Count > 0 - && (runningSongMediaConversionCoroutines.Count < settings.MaxConcurrentSongMediaConversions - || settings.MaxConcurrentSongMediaConversions <= 0)) - { - IEnumerator coroutine = pendingSongMediaConversionCoroutines[0]; - pendingSongMediaConversionCoroutines.RemoveAt(0); - runningSongMediaConversionCoroutines.Add(coroutine); - Debug.Log($"Started conversion coroutine. Now running conversion coroutines: {runningSongMediaConversionCoroutines.Count}"); - - StartCoroutine(CoroutineUtils.Sequence(coroutine, - CoroutineUtils.ExecuteAction(() => - { - runningSongMediaConversionCoroutines.Remove(coroutine); - Debug.Log($"Finished conversion coroutine. Now running conversion coroutines: {runningSongMediaConversionCoroutines.Count}"); - }))); - } - } - - private void ConvertSongMetaMediaFileToSupportedFormat( - SongMeta songMeta, - string mediaDescription, - Func pathGetter, - Action pathSetter, - Translation jobTitle, - bool isAudio) - { - ConvertSongMetaMediaFileToSupportedFormatWithRetry( - songMeta, - mediaDescription, - pathGetter, - pathSetter, - jobTitle, - isAudio); - } - - private void ConvertSongMetaMediaFileToSupportedFormatWithRetry( - SongMeta songMeta, - string mediaDescription, - Func pathGetter, - Action pathSetter, - Translation jobTitle, - bool isAudio) - { - string currentValue = pathGetter(); - if (currentValue.IsNullOrEmpty()) - { - return; - } - - string sourceFilePath = SongMetaUtils.GetAbsoluteFilePath(songMeta, currentValue); - if (!FileUtils.Exists(sourceFilePath)) - { - Debug.LogError($"Cannot convert file '{sourceFilePath}', file does not exist"); - return; - } - - void OnSuccess(string targetFilePath) - { - string relativeTargetFilePath = PathUtils.MakeRelativePath(SongMetaUtils.GetDirectoryPath(songMeta), targetFilePath); - Debug.Log($"Setting {mediaDescription} of '{SongMetaUtils.GetAbsoluteSongMetaFilePath(songMeta)}' to '{relativeTargetFilePath}'"); - pathSetter(relativeTargetFilePath); - songMetaManager.SaveSong(songMeta, true); - songMetaManager.ReloadSong(songMeta); - Debug.Log($"Successfully converted {mediaDescription} of '{SongMetaUtils.GetAbsoluteSongMetaFilePath(songMeta)}' to '{relativeTargetFilePath}'"); - NotificationManager.CreateNotification(Translation.Get(R.Messages.common_convertMediaSuccess, - "name", songMeta.GetArtistDashTitle())); - } - - void OnFailure(ConversionError conversionError) - { - NotificationManager.CreateNotification(Translation.Get(R.Messages.common_error_failedToConvert, - "name", songMeta.GetArtistDashTitle())); - } - - ConvertFileToSupportedFormat(sourceFilePath, - mediaDescription, - jobTitle, - isAudio, - true, - MaxConversionRetry, - OnSuccess, - OnFailure); - } - - private static ConversionError GetConversionError(string sourceFilePath, string targetFilePath) - { - if (!FileUtils.Exists(targetFilePath)) - { - return new ConversionError( - sourceFilePath, - targetFilePath, - $"Failed to convert file '{sourceFilePath}'. Target file not found: {targetFilePath}", - false); - } - - long targetFileSizeInBytes = new FileInfo(targetFilePath).Length; - if (targetFileSizeInBytes < MinTargetFileSizeInBytes) - { - return new ConversionError( - sourceFilePath, - targetFilePath, - $"Failed to convert file '{sourceFilePath}'. Target file is too small: '{targetFilePath}', size in bytes: {targetFileSizeInBytes}", - true); - } - - return null; - } - - public void ConvertFileToSupportedFormat( - string sourceFilePath, - string mediaDescription, - Translation jobTitle, - bool isAudio, - bool ignoreEqualFileExtension, - int maxRetry, - Action onSuccess, - Action onFailure) - { - if (!FileUtils.Exists(sourceFilePath)) - { - Debug.Log($"File not found '{sourceFilePath}'"); - NotificationManager.CreateNotification(Translation.Get(R.Messages.common_error_fileNotFoundWithName, - "name", sourceFilePath)); - return; - } - - string sourceFileExtension = PathUtils.GetExtensionWithoutDot(sourceFilePath); - string sourceFilePathWithoutExtension = $"{Path.GetDirectoryName(sourceFilePath)}/{Path.GetFileNameWithoutExtension(sourceFilePath)}"; - if (!settings.FileFormatToFfmpegConversionArguments.TryGetValue(sourceFileExtension, out string ffmpegArgumentsWithPlaceholders)) - { - if ((isAudio && !settings.FileFormatToFfmpegConversionArguments.TryGetValue("ANY_AUDIO", out ffmpegArgumentsWithPlaceholders)) - || (!isAudio && !settings.FileFormatToFfmpegConversionArguments.TryGetValue("ANY_VIDEO", out ffmpegArgumentsWithPlaceholders))) - { - ffmpegArgumentsWithPlaceholders = isAudio - ? $"-y -i \"INPUT_FILE\" \"INPUT_FILE_WITHOUT_EXTENSION.ogg\"" - : $"-y -i \"INPUT_FILE\" -c:v libvpx -c:a libvorbis \"INPUT_FILE_WITHOUT_EXTENSION.webm\""; - } - } - - string ffmpegArguments = ffmpegArgumentsWithPlaceholders - // Replace longer placeholders first - .Replace("INPUT_FILE_WITHOUT_EXTENSION", $"{sourceFilePathWithoutExtension}") - .Replace("INPUT_FILE", sourceFilePath); - - string targetFileName = GetTargetFileNameFromFfmpegArguments(ffmpegArguments); - if (targetFileName.IsNullOrEmpty()) - { - Debug.Log($"Unable to determine target file name for '{sourceFilePath}'"); - NotificationManager.CreateNotification(Translation.Get(R.Messages.common_error)); - return; - } - - string targetFileExtension = PathUtils.GetExtensionWithoutDot(targetFileName); - if (targetFileExtension.IsNullOrEmpty()) - { - Debug.Log($"Unable to determine target file extension for '{sourceFilePath}'"); - NotificationManager.CreateNotification(Translation.Get(R.Messages.common_error)); - return; - } - - if (string.Equals(sourceFileExtension, targetFileExtension, StringComparison.InvariantCultureIgnoreCase) - && !ignoreEqualFileExtension) - { - // Nothing to do - return; - } - - bool canConvertToSupportedFormat = isAudio - ? ApplicationUtils.IsFfmpegSupportedAudioFormat(sourceFileExtension) - : ApplicationUtils.IsFfmpegSupportedVideoFormat(sourceFileExtension); - if (!canConvertToSupportedFormat) - { - Debug.Log($"Cannot convert {mediaDescription} '{sourceFileExtension}' to supported format"); - NotificationManager.CreateNotification(Translation.Get(R.Messages.common_error)); - return; - } - - string targetFolder = Path.GetDirectoryName(sourceFilePath); - string targetFilePath = $"{targetFolder}/{targetFileName}"; - - Debug.Log($"Converting {mediaDescription} of '{sourceFilePath}' to '{targetFilePath}'"); - FfmpegCommand ffmpegCommand = CreateFfmpegCommandOnNewGameObject(jobTitle, ffmpegArguments); - - // Create UI job - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - Job uiJob = new(jobTitle); - uiJob.OnCancel = () => - { - uiJob.SetResult(EJobResult.Error); - cancellationTokenSource.Cancel(); - ffmpegCommand.StopFfmpeg(); - }; - jobManager.AddJob(uiJob); - - IEnumerator runFfmpegCommandCoroutine = RunFfmpegCommandCoroutine(ffmpegCommand, uiJob, cancellationTokenSource.Token, () => - { - if (cancellationTokenSource.IsCancellationRequested) - { - return; - } - - ConversionError conversionError = GetConversionError(sourceFilePath, targetFilePath); - if (conversionError == null) - { - onSuccess?.Invoke(targetFilePath); - } - else - { - if (conversionError.CanRetry - && maxRetry > 0) - { - Debug.LogError($"{conversionError.ErrorMessage}. Remaining retry count: {maxRetry}. Attempting retry."); - ConvertFileToSupportedFormat( - sourceFilePath, - mediaDescription, - jobTitle, - isAudio, - ignoreEqualFileExtension, - maxRetry - 1, - onSuccess, - onFailure); - return; - } - else if (conversionError.CanRetry - && maxRetry <= 0) - { - Debug.LogError($"{conversionError.ErrorMessage}. Failed last retry."); - onFailure?.Invoke(conversionError); - } - else - { - Debug.LogError($"{conversionError.ErrorMessage}. Cannot retry."); - onFailure?.Invoke(conversionError); - } - } - }); - - pendingSongMediaConversionCoroutines.Add(runFfmpegCommandCoroutine); - } - - public static string GetTargetFileNameFromFfmpegArguments(string ffmpegArguments) - { - // Return the last found file name - MatchCollection matches = Regex.Matches(ffmpegArguments, @"(/|\\)(?[^/\\]+)\.(?\w+)"); - if (matches.Count == 0) - { - return ""; - } - - Match lastMatch = matches.LastOrDefault(); - string fileExtension = lastMatch.Groups["extension"].Value.ToLowerInvariant(); - string fileNameWithoutExtension = lastMatch.Groups["fileNameWithoutExtension"].Value; - string fileName = $"{fileNameWithoutExtension}.{fileExtension}"; - return fileName; - } - - public void ConvertVocalsAudioToSupportedFormat(SongMeta songMeta) - { - ConvertSongMetaMediaFileToSupportedFormat( - songMeta, - "vocals audio", - () => songMeta.VocalsAudio, - newValue => songMeta.VocalsAudio = newValue, - Translation.Get(R.Messages.job_convertVocalsAudioWithName, - "name", songMeta.GetArtistDashTitle()), - true); - } - - public void ConvertInstrumentalAudioToSupportedFormat(SongMeta songMeta) - { - ConvertSongMetaMediaFileToSupportedFormat( - songMeta, - "instrumental audio", - () => songMeta.InstrumentalAudio, - newValue => songMeta.InstrumentalAudio = newValue, - Translation.Get(R.Messages.job_convertInstrumentalAudioWithName, - "name", songMeta.GetArtistDashTitle()), - true); - } - - public void ConvertAudioToSupportedFormat(SongMeta songMeta) - { - // The MP3 tag can also be used with a video file. - string fileExtension = PathUtils.GetExtensionWithoutDot(songMeta.Audio); - bool isAudio = ApplicationUtils.audioFileExtensions.Contains(fileExtension); - - ConvertSongMetaMediaFileToSupportedFormat( - songMeta, - "audio", - () => songMeta.Audio, - newValue => songMeta.Audio = newValue, - Translation.Get(R.Messages.job_convertAudioWithName, - "name", songMeta.GetArtistDashTitle()), - isAudio); - } - - public void ConvertVideoToSupportedFormat(SongMeta songMeta) - { - ConvertSongMetaMediaFileToSupportedFormat( - songMeta, - "video", - () => songMeta.Video, - newValue => songMeta.Video = newValue, - Translation.Get(R.Messages.job_convertVideoWithName, - "name", songMeta.GetArtistDashTitle()), - false); - } - - private IEnumerator RunFfmpegCommandCoroutine(FfmpegCommand ffmpegCommand, Job uiJob, CancellationToken cancellationToken, Action onSuccess) - { - if (cancellationToken.IsCancellationRequested) - { - Debug.Log($"Not executing ffmpeg command '{ffmpegCommand.Options}'. Cancelled."); - yield break; - } - - Debug.Log($"Executing ffmpeg command '{ffmpegCommand.Options}'"); - - uiJob.SetStatus(EJobStatus.Running); - ffmpegCommand.StartFfmpeg(); - yield return new WaitForSeconds(0.1f); - - while (ffmpegCommand.IsRunning - && !ffmpegCommand.IsFinished) - { - if (ffmpegCommand.DurationTime.TotalMilliseconds > uiJob.EstimatedTotalDurationInMillis) - { - uiJob.EstimatedTotalDurationInMillis = (long)ffmpegCommand.DurationTime.TotalMilliseconds; - } - - double newProgressInPercent = Math.Floor(ffmpegCommand.Progress * 100.0); - if (newProgressInPercent > uiJob.EstimatedCurrentProgressInPercent) - { - uiJob.EstimatedCurrentProgressInPercent = newProgressInPercent; - } - yield return new WaitForSeconds(0.1f); - } - - if (cancellationToken.IsCancellationRequested) - { - Debug.Log($"FfmpegCommand not finished: '{uiJob.Name}'. Cancelled."); - yield break; - } - - uiJob.SetResult(EJobResult.Ok); - - Debug.Log($"FfmpegCommand finished: {uiJob.Name}"); - Destroy(ffmpegCommand.gameObject); - - if (onSuccess != null) - { - try - { - onSuccess.Invoke(); - } - catch (Exception e) - { - Debug.LogException(e); - Debug.LogError($"Failed to invoke onSuccess callback after running ffmpeg command '{ffmpegCommand.Options}'"); - } - } - } - - private FfmpegCommand CreateFfmpegCommandOnNewGameObject(string gameObjectName, string ffmpegArguments) - { - GameObject ffmpegGameObject = new GameObject($"FfmpegCommand '{gameObjectName}'"); - ffmpegGameObject.transform.SetParent(transform); - FfmpegCommand ffmpegCommand = ffmpegGameObject.AddComponent(); - ffmpegCommand.Options = ffmpegArguments; - ffmpegCommand.ExecuteOnStart = false; - ffmpegCommand.GetProgressOnScript = true; - ffmpegCommand.PrintStdErr = settings.LogFfmpegOutput; - return ffmpegCommand; - } - - public class ConversionError - { - public string SourceFilePath { get; private set; } - public string TargetFilePath { get; private set; } - public string ErrorMessage { get; private set; } - public bool CanRetry { get; private set; } - - public ConversionError( - string sourceFilePath, - string targetFilePath, - string errorMessage, - bool canRetry) - { - SourceFilePath = sourceFilePath; - TargetFilePath = targetFilePath; - ErrorMessage = errorMessage; - CanRetry = canRetry; - } - } -} diff --git a/UltraStar Play/Assets/Common/SongMediaFileConversion/SongMediaFileConversionManager.cs.meta b/UltraStar Play/Assets/Common/SongMediaFileConversion/SongMediaFileConversionManager.cs.meta deleted file mode 100644 index 82b641868..000000000 --- a/UltraStar Play/Assets/Common/SongMediaFileConversion/SongMediaFileConversionManager.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 998caedc1a8d42fb86616e21b51a656a -timeCreated: 1689351030 \ No newline at end of file diff --git a/UltraStar Play/Assets/Common/Video/SongVideoPlayer/FfmpegVideoSupportProvider.cs b/UltraStar Play/Assets/Common/Video/SongVideoPlayer/FfmpegVideoSupportProvider.cs deleted file mode 100644 index 73372a5de..000000000 --- a/UltraStar Play/Assets/Common/Video/SongVideoPlayer/FfmpegVideoSupportProvider.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.IO; -using UniInject; -using UniRx; -using UnityEngine; - -public class FfmpegVideoSupportProvider : AbstractVideoSupportProvider -{ - [Inject] - private SongAudioPlayer songAudioPlayer; - - public override bool IsSupported(string videoUri, bool videoEqualsAudio) - { - return !WebRequestUtils.IsHttpOrHttpsUri(videoUri) - && settings.FfmpegToPlayMediaFilesUsage is not EThirdPartyLibraryUsage.Never - && ApplicationUtils.IsFfmpegSupportedAudioFormat(Path.GetExtension(videoUri)); - } - - public override IObservable LoadAsObservable(string videoUri, double startPositionInMillis) - { - // Loading is done by SongAudioPlayer - return Observable.Return(new VideoLoadedEvent(videoUri)); - } - - public override void Unload() - { - ResetFfmpegRenderTexture(); - } - - public override void Play() - { - // Handled by SongAudioPlayer - } - - public override void Pause() - { - // Handled by SongAudioPlayer - } - - public override void Stop() - { - // Handled by SongAudioPlayer - } - - public override bool IsPlaying - { - get => songAudioPlayer.IsPlaying; - set - { - if (value) - { - Play(); - } - else - { - Pause(); - } - } - } - - public override bool IsLooping - { - get => false; - set { /* Not supported */ } - } - - public override double PlaybackSpeed - { - get => 1; - set { /* Not supported */ } - } - - public override double PositionInMillis - { - get => songAudioPlayer.PositionInMillis; - set => songAudioPlayer.PositionInMillis = value; - } - - public override double DurationInMillis => songAudioPlayer.DurationInMillis; - - public override void SetTargetTexture(RenderTexture renderTexture) - { - if (renderTexture != null) - { - SetFfmpegRenderTextureToVideoRenderTexture(renderTexture); - } - else - { - ResetFfmpegRenderTexture(); - } - } - - private void SetFfmpegRenderTextureToVideoRenderTexture(RenderTexture renderTexture) - { - songAudioPlayer.FfmpegRenderTexture = renderTexture; - } - - private void ResetFfmpegRenderTexture() - { - songAudioPlayer.FfmpegRenderTexture = null; - } -} diff --git a/UltraStar Play/Assets/Common/Video/SongVideoPlayer/FfmpegVideoSupportProvider.cs.meta b/UltraStar Play/Assets/Common/Video/SongVideoPlayer/FfmpegVideoSupportProvider.cs.meta deleted file mode 100644 index ba2f0492e..000000000 --- a/UltraStar Play/Assets/Common/Video/SongVideoPlayer/FfmpegVideoSupportProvider.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 36ab02965ce44c45997229b3c09fec0d -timeCreated: 1715452756 \ No newline at end of file diff --git a/UltraStar Play/Assets/FfmpegUnity/Editor/FfmpegUnity.Editor.asmdef b/UltraStar Play/Assets/FfmpegUnity/Editor/FfmpegUnity.Editor.asmdef deleted file mode 100644 index f3285d70a..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/Editor/FfmpegUnity.Editor.asmdef +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "FfmpegUnity.Editor", - "rootNamespace": "", - "references": [ - "GUID:f859d57385b397a4cbcf69b5373882cc" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/UltraStar Play/Assets/FfmpegUnity/Editor/FfmpegUnity.Editor.asmdef.meta b/UltraStar Play/Assets/FfmpegUnity/Editor/FfmpegUnity.Editor.asmdef.meta deleted file mode 100644 index 5de84bfc5..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/Editor/FfmpegUnity.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 2536d47cc3dfbfa4a83d0789a92258dd -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnity.asmdef b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnity.asmdef deleted file mode 100644 index 8122e3d97..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnity.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "FfmpegUnity", - "rootNamespace": "", - "references": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnity.asmdef.meta b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnity.asmdef.meta deleted file mode 100644 index 165ec0c8b..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnity.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: f859d57385b397a4cbcf69b5373882cc -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegCommand.cs b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegCommand.cs deleted file mode 100644 index 672577eb7..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegCommand.cs +++ /dev/null @@ -1,30 +0,0 @@ -#if HAS_FFMPEG_UNITY -#else - -using System; -using UnityEngine; - -namespace FfmpegUnity -{ - public class FfmpegCommand : MonoBehaviour - { - public string Options { get; set; } - public bool IsRunning { get; set; } - public bool IsFinished { get; set; } - public TimeSpan DurationTime { get; set; } - public double Progress { get; set; } - public bool ExecuteOnStart { get; set; } - public bool GetProgressOnScript { get; set; } - public bool PrintStdErr { get; set; } - - public void StartFfmpeg() - { - } - - public void StopFfmpeg() - { - } - } -} - -#endif diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegCommand.cs.meta b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegCommand.cs.meta deleted file mode 100644 index 7aef0ec02..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegCommand.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: fcb41d63beda468eb61a0b1c53bf9c8f -timeCreated: 1718550850 \ No newline at end of file diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegPlayerVideoTexture.cs b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegPlayerVideoTexture.cs deleted file mode 100644 index 4771e07e5..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegPlayerVideoTexture.cs +++ /dev/null @@ -1,14 +0,0 @@ -#if HAS_FFMPEG_UNITY -#else - -using UnityEngine; - -namespace FfmpegUnity -{ - public class FfmpegPlayerVideoTexture - { - public RenderTexture VideoTexture { get; set; } - } -} - -#endif diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegPlayerVideoTexture.cs.meta b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegPlayerVideoTexture.cs.meta deleted file mode 100644 index bbbf79538..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfmpegPlayerVideoTexture.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 8214c171d19d4252894e17c932445436 -timeCreated: 1718550362 \ No newline at end of file diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayAudio.cs b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayAudio.cs deleted file mode 100644 index d48e4fdc1..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayAudio.cs +++ /dev/null @@ -1,16 +0,0 @@ -#if HAS_FFMPEG_UNITY -#else - -using UnityEngine; - -namespace FfmpegUnity -{ - public class FfplayAudio : MonoBehaviour - { - protected virtual void OnAudioFilterRead(float[] data, int channels) - { - } - } -} - -#endif diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayAudio.cs.meta b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayAudio.cs.meta deleted file mode 100644 index 11eee4ffc..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayAudio.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 9dceb5efc2be4f85a7367811b9bd5a98 -timeCreated: 1718550923 \ No newline at end of file diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayCommand.cs b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayCommand.cs deleted file mode 100644 index 54ce20216..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayCommand.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if HAS_FFMPEG_UNITY -#else - -using UnityEngine; - -namespace FfmpegUnity -{ - public class FfplayCommand : MonoBehaviour - { - public FfmpegPlayerVideoTexture VideoTexture { get; set; } - public string InputPath { get; set; } - public bool Paused { get; set; } - public bool IsRunning { get; set; } - public double CurrentTime { get; set; } - public double Duration { get; set; } - public AudioSource AudioSourceComponent { get; set; } - - public void Play() - { - } - - public void Stop() - { - } - - public void TogglePause() - { - } - - public void SeekTime(double value) - { - } - } -} - -#endif diff --git a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayCommand.cs.meta b/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayCommand.cs.meta deleted file mode 100644 index 8efe84b66..000000000 --- a/UltraStar Play/Assets/FfmpegUnity/FfmpegUnityDummy/FfplayCommand.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 296524447a6c404185b92f7a0633c54f -timeCreated: 1718550351 \ No newline at end of file diff --git a/UltraStar Play/Assets/PlayModeTests/MediaFileFormatTests/FileFormatConversionTest.cs b/UltraStar Play/Assets/PlayModeTests/MediaFileFormatTests/FileFormatConversionTest.cs deleted file mode 100644 index 8da4c3986..000000000 --- a/UltraStar Play/Assets/PlayModeTests/MediaFileFormatTests/FileFormatConversionTest.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.IO; -using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; - -[Ignore("No ffmpeg present in the project")] -public class FileFormatConversionTest : AbstractMediaFileFormatTest -{ - private static readonly string tempFolder = $"{Application.temporaryCachePath}/MediaFileConversionTest"; - - private static readonly List fileNamesWithAudioSupportedByFfmpeg = new List() - { - new TestCaseData("aac.txt").Returns(null), - new TestCaseData("aiff.txt").Returns(null), - new TestCaseData("flac.txt").Returns(null), - }; - - private static readonly List fileNamesWithVideoSupportedByFfmpeg = new List() - { - new TestCaseData("f4v.txt").Returns(null), - new TestCaseData("flv.txt").Returns(null), - new TestCaseData("mkv.txt").Returns(null), - new TestCaseData("mov.txt").Returns(null), - new TestCaseData("mpeg2.txt").Returns(null), - new TestCaseData("webm-vp9.txt").Returns(null), - new TestCaseData("wmv.txt").Returns(null), - }; - - [OneTimeSetUp] - public void DeleteTempFolder() - { - DirectoryUtils.Delete(tempFolder, true); - } - - [Test] - public void ShouldReturnTargetFileNameFromFfmpegArguments() - { - string targetFileName = SongMediaFileConversionManager.GetTargetFileNameFromFfmpegArguments( - "-y -i \"F:/Dev/UltraStar-Songs-Dev/Some Artist - Some Title/Some Artist - Some Title.mp4\" -c:v libvpx -c:a libvorbis \"F:/Dev/UltraStar-Songs-Dev/Some Artist - Some Title/Some Artist - Some Title-vp8.webm\""); - Assert.AreEqual("Some Artist - Some Title-vp8.webm", targetFileName); - - string targetFileName2 = SongMediaFileConversionManager.GetTargetFileNameFromFfmpegArguments( - "-y -i \"F:\\Dev\\UltraStar-Songs-Dev\\Some Artist - Some Title\\Some Artist - Some Title.mp4\" -c:v libvpx -c:a libvorbis \"F:\\Dev\\UltraStar-Songs-Dev\\Some Artist - Some Title\\Some Artist - Some Title-vp8.webm\""); - Assert.AreEqual("Some Artist - Some Title-vp8.webm", targetFileName2); - } - - [UnityTest] - [TestCaseSource(nameof(fileNamesWithAudioSupportedByFfmpeg))] - public IEnumerator ShouldConvertAudio(string txtFilePath) - { - yield return ShouldConvertFile(txtFilePath, true); - } - - [UnityTest] - [TestCaseSource(nameof(fileNamesWithVideoSupportedByFfmpeg))] - public IEnumerator ShouldConvertVideo(string txtFilePath) - { - return ShouldConvertFile(txtFilePath, false); - } - - private IEnumerator ShouldConvertFile(string txtFilePath, bool isAudio) - { - LogAssert.ignoreFailingMessages = true; - - string songFilePath = GetSongMetaFilePath(txtFilePath); - SongMeta songMeta = LoadSongMeta(songFilePath); - string originalSourceFilePath = SongMetaUtils.GetAbsoluteFilePath(songMeta, songMeta.Audio); - - // Copy file to temp folder so that we don't modify the original file - string tempSourceFilePath = $"{tempFolder}/{Path.GetFileName(originalSourceFilePath)}"; - FileUtils.Copy(originalSourceFilePath, tempSourceFilePath, true); - - long copyStartTimeInMillis = TimeUtils.GetUnixTimeMilliseconds(); - while (!File.Exists(tempSourceFilePath)) - { - if (TimeUtils.IsDurationAboveThresholdInMillis(copyStartTimeInMillis, 1000)) - { - Assert.Fail($"Failed to copy file {originalSourceFilePath} to {tempSourceFilePath}"); - yield break; - } - yield return new WaitForEndOfFrame(); - } - - bool isSuccessful = false; - int maxRetry = 3; - long conversionStartTimeInMillis = TimeUtils.GetUnixTimeMilliseconds(); - SongMediaFileConversionManager.MinTargetFileSizeInBytes = 10 * 1024; // 10 KB - SongMediaFileConversionManager.Instance.ConvertFileToSupportedFormat(tempSourceFilePath, - $"test media '{Path.GetFileName(tempSourceFilePath)}'", - Translation.Of($"Convert '{Path.GetFileName(tempSourceFilePath)}' to supported format"), - isAudio, - true, - maxRetry, - targetFilePath => - { - if (!File.Exists(targetFilePath)) - { - Assert.Fail($"Failed to convert '{tempSourceFilePath}' to supported format. Target file '{targetFilePath}' does not exist"); - return; - } - - isSuccessful = true; - long durationInMillis = TimeUtils.GetUnixTimeMilliseconds() - conversionStartTimeInMillis; - Debug.Log($"Successfully converted '{originalSourceFilePath}' to '{Path.GetFileName(targetFilePath)}' in {durationInMillis} ms"); - }, - conversionError => - { - Assert.Fail($"Failed to convert '{tempSourceFilePath}' to supported format. Conversion error: {conversionError.ErrorMessage}"); - }); - - long maxWaitTimeInMillis = 3000; - yield return new WaitUntil(() => isSuccessful - || TimeUtils.IsDurationAboveThresholdInMillis(conversionStartTimeInMillis, maxWaitTimeInMillis)); - - if (!isSuccessful) - { - Assert.Fail($"Failed to convert '{originalSourceFilePath}' to supported format within {maxWaitTimeInMillis} ms"); - } - } -} diff --git a/UltraStar Play/Assets/PlayModeTests/MediaFileFormatTests/FileFormatConversionTest.cs.meta b/UltraStar Play/Assets/PlayModeTests/MediaFileFormatTests/FileFormatConversionTest.cs.meta deleted file mode 100644 index 9e3c8ccb2..000000000 --- a/UltraStar Play/Assets/PlayModeTests/MediaFileFormatTests/FileFormatConversionTest.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f50e480bede84154082dce3528cbcdff -timeCreated: 1689254187 \ No newline at end of file diff --git a/UltraStar Play/Assets/Scenes/Options/SongLibraryOptions/SongLibraryOptionsSceneControl.cs b/UltraStar Play/Assets/Scenes/Options/SongLibraryOptions/SongLibraryOptionsSceneControl.cs index 24f118a7a..6dba4ea5e 100644 --- a/UltraStar Play/Assets/Scenes/Options/SongLibraryOptions/SongLibraryOptionsSceneControl.cs +++ b/UltraStar Play/Assets/Scenes/Options/SongLibraryOptions/SongLibraryOptionsSceneControl.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using UniInject; @@ -32,9 +32,6 @@ public class SongLibraryOptionsSceneControl : AbstractOptionsSceneControl, INeed [Inject] private UIDocument uiDocument; - [Inject] - private SongMediaFileConversionManager songMediaFileConversionManager; - [Inject] private UiManager uiManager; @@ -411,59 +408,16 @@ private void FillWithSongIssues(AccordionItem accordionItem, IReadOnlyList quickFixActions) - { - if (songIssue.SongIssueData is FormatNotSupportedSongIssueData formatNotSupportedSongIssueData) - { - if (formatNotSupportedSongIssueData.MediaType == FormatNotSupportedSongIssueData.EMediaType.InstrumentalAudio) - { - Action quickFixAction = () => songMediaFileConversionManager.ConvertInstrumentalAudioToSupportedFormat(songIssue.SongMeta); - Button quickFixButton = CreateQuickFixButton(Translation.Get(R.Messages.options_songLibrary_action_quickFix_instrumentalAudioFormat), quickFixAction); - quickFixActions.Add(new QuickFixAction(songIssue.SongIssueData, - Translation.Get(R.Messages.options_songLibrary_action_quickFix_instrumentalAudioFormat), - quickFixAction)); - parent.Add(quickFixButton); - } - else if (formatNotSupportedSongIssueData.MediaType == FormatNotSupportedSongIssueData.EMediaType.VocalsAudio) - { - Action quickFixAction = () => songMediaFileConversionManager.ConvertVocalsAudioToSupportedFormat(songIssue.SongMeta); - Button quickFixButton = CreateQuickFixButton(Translation.Get(R.Messages.options_songLibrary_action_quickFix_vocalsAudioFormat), quickFixAction); - quickFixActions.Add(new QuickFixAction(songIssue.SongIssueData, - Translation.Get(R.Messages.options_songLibrary_action_quickFix_vocalsAudioFormat), - quickFixAction)); - parent.Add(quickFixButton); - } - else if (formatNotSupportedSongIssueData.MediaType == FormatNotSupportedSongIssueData.EMediaType.Audio) - { - Action quickFixAction = () => songMediaFileConversionManager.ConvertAudioToSupportedFormat(songIssue.SongMeta); - Button quickFixButton = CreateQuickFixButton(Translation.Get(R.Messages.options_songLibrary_action_quickFix_audioFormat), quickFixAction); - quickFixActions.Add(new QuickFixAction(songIssue.SongIssueData, - Translation.Get(R.Messages.options_songLibrary_action_quickFix_audioFormat), - quickFixAction)); - parent.Add(quickFixButton); - } - else if (formatNotSupportedSongIssueData.MediaType == FormatNotSupportedSongIssueData.EMediaType.Video) - { - Action quickFixAction = () => songMediaFileConversionManager.ConvertVideoToSupportedFormat(songIssue.SongMeta); - Button quickFixButton = CreateQuickFixButton(Translation.Get(R.Messages.options_songLibrary_action_quickFix_videoFormat), quickFixAction); - quickFixActions.Add(new QuickFixAction(songIssue.SongIssueData, - Translation.Get(R.Messages.options_songLibrary_action_quickFix_videoFormat), - quickFixAction)); - parent.Add(quickFixButton); - } - } - } - private VisualElement CreateAddSongIssueListSongEntry(SongIssue songIssue) { string songMetaArtistAndTitle = songIssue.SongMeta != null