diff --git a/AudioCuesheetEditor/Pages/ViewModeImport.razor b/AudioCuesheetEditor/Pages/ViewModeImport.razor index 4d47ca2f..d3fb4ca3 100644 --- a/AudioCuesheetEditor/Pages/ViewModeImport.razor +++ b/AudioCuesheetEditor/Pages/ViewModeImport.razor @@ -356,6 +356,19 @@ along with Foobar. If not, see { _sessionStateContainer.ResetImport(); var importedFiles = await _importManager.ImportFilesAsync(files); + // Audio file is handled seperatly + foreach (var file in files) + { + if (IOUtility.CheckFileMimeTypeForAudioCodec(file)) + { + var audioFileObjectURL = await _jsRuntime.InvokeAsync("getObjectURL", "dropFileInput"); + var codec = IOUtility.GetAudioCodec(file); + var audiofile = new Audiofile(file.Name, audioFileObjectURL, codec, _httpClient); + _ = audiofile.LoadContentStream(); + _sessionStateContainer.ImportAudiofile = audiofile; + importedFiles.Add(file, ImportFileType.Audiofile); + } + } displaySplitPoints = importedFiles.ContainsValue(ImportFileType.ProjectFile); await OnSelectedStepChanged("validateData"); StateHasChanged(); diff --git a/AudioCuesheetEditor/Services/IO/ImportManager.cs b/AudioCuesheetEditor/Services/IO/ImportManager.cs index a0a64098..4674a40d 100644 --- a/AudioCuesheetEditor/Services/IO/ImportManager.cs +++ b/AudioCuesheetEditor/Services/IO/ImportManager.cs @@ -34,12 +34,10 @@ public enum ImportFileType Textfile, Audiofile } - public class ImportManager(SessionStateContainer sessionStateContainer, LocalStorageOptionsProvider localStorageOptionsProvider, IJSRuntime jsRuntime, HttpClient httpClient, TextImportService textImportService, CuesheetImportService cuesheetImportService) + public class ImportManager(SessionStateContainer sessionStateContainer, LocalStorageOptionsProvider localStorageOptionsProvider, TextImportService textImportService, CuesheetImportService cuesheetImportService) { private readonly SessionStateContainer _sessionStateContainer = sessionStateContainer; private readonly LocalStorageOptionsProvider _localStorageOptionsProvider = localStorageOptionsProvider; - private readonly IJSRuntime _jsRuntime = jsRuntime; - private readonly HttpClient _httpClient = httpClient; private readonly TextImportService _textImportService = textImportService; private readonly CuesheetImportService _cuesheetImportService = cuesheetImportService; @@ -84,15 +82,6 @@ public async Task> ImportFilesAsync(IEnum await ImportTextAsync([.. lines]); importFileTypes.Add(file, ImportFileType.Textfile); } - if (IOUtility.CheckFileMimeTypeForAudioCodec(file)) - { - var audioFileObjectURL = await _jsRuntime.InvokeAsync("getObjectURL", "dropFileInput"); - var codec = IOUtility.GetAudioCodec(file); - var audiofile = new Audiofile(file.Name, audioFileObjectURL, codec, _httpClient); - _ = audiofile.LoadContentStream(); - _sessionStateContainer.ImportAudiofile = audiofile; - importFileTypes.Add(file, ImportFileType.Audiofile); - } } return importFileTypes; }