Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task DownloadProject_GeneratesProjectFile_WhenCuesheetIsValidAsync(
using var stream = await download.CreateReadStreamAsync();
using var reader = new StreamReader(stream);
var content = await reader.ReadToEndAsync(TestContext.CancellationToken);
Assert.AreEqual("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Track Artist 1\",\"Title\":\"Track Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:05:48\",\"Flags\":[],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"Cuesheet Artist 1\",\"Title\":\"Cuesheet Title 1\",\"Audiofile\":{\"Name\":\"Kalimba.mp3\",\"Duration\":\"00:05:48\",\"AudioCodec\":{\"MimeType\":\"audio/mpeg\",\"FileExtension\":\".mp3\",\"Name\":\"AudioCodec MP3\"}}}", content);
Assert.AreEqual("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Track Artist 1\",\"Title\":\"Track Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:05:48.0608330\",\"Flags\":[],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"Cuesheet Artist 1\",\"Title\":\"Cuesheet Title 1\",\"Audiofile\":{\"Name\":\"Kalimba.mp3\",\"Duration\":\"00:05:48.0608330\",\"AudioCodec\":{\"MimeType\":\"audio/mpeg\",\"FileExtension\":\".mp3\",\"Name\":\"AudioCodec MP3\"}}}", content);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task DownloadProject_GeneratesProjectFile_WhenCuesheetIsValidAsync(
using var stream = await download.CreateReadStreamAsync();
using var reader = new StreamReader(stream);
var content = await reader.ReadToEndAsync(TestContext.CancellationToken);
Assert.AreEqual("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Track Artist 1\",\"Title\":\"Track Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:05:48\",\"Flags\":[],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"Cuesheet Artist 1\",\"Title\":\"Cuesheet Title 1\",\"Audiofile\":{\"Name\":\"Kalimba.mp3\",\"Duration\":\"00:05:48\",\"AudioCodec\":{\"MimeType\":\"audio/mpeg\",\"FileExtension\":\".mp3\",\"Name\":\"AudioCodec MP3\"}}}", content);
Assert.AreEqual("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Track Artist 1\",\"Title\":\"Track Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:05:48.0608330\",\"Flags\":[],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"Cuesheet Artist 1\",\"Title\":\"Cuesheet Title 1\",\"Audiofile\":{\"Name\":\"Kalimba.mp3\",\"Duration\":\"00:05:48.0608330\",\"AudioCodec\":{\"MimeType\":\"audio/mpeg\",\"FileExtension\":\".mp3\",\"Name\":\"AudioCodec MP3\"}}}", content);
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion AudioCuesheetEditor.Tests/AudioCuesheetEditor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="coverlet.collector" Version="8.0.0">
<PackageReference Include="coverlet.collector" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 2 additions & 8 deletions AudioCuesheetEditor.Tests/Model/AudioCuesheet/CuesheetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,9 @@ public void StartRecording_WithAudiofile_ShouldStartRecording()
public void RecalculateLastTrackEnd_SingleTrackWithAudiofile_EndSetToAudiofileDuration()
{
// Arrange
var audiofileMock = new Mock<IAudiofile>();
audiofileMock.SetupGet(a => a.Duration).Returns(TimeSpan.FromMinutes(5));

var cuesheet = new Cuesheet
{
Audiofile = audiofileMock.Object
Audiofile = new("Test.mp3", nameof(RecalculateLastTrackEnd_SingleTrackWithAudiofile_EndSetToAudiofileDuration), new AudioCodec("audio/mpeg", ".mp3", "AudioCodec MP3"), TimeSpan.FromMinutes(5))
};
var track = new Track { Position = 1, Begin = TimeSpan.Zero };
cuesheet.AddTrack(track);
Expand Down Expand Up @@ -712,12 +709,9 @@ public void RecalculateLastTrackEnd_MultipleTracks_EndSetCorrectly()
public void RecalculateLastTrackEnd_MultipleTracksWithAudiofile_LastTrackEndSetToAudiofileDuration()
{
// Arrange
var audiofileMock = new Mock<IAudiofile>();
audiofileMock.SetupGet(a => a.Duration).Returns(TimeSpan.FromMinutes(5));

var cuesheet = new Cuesheet
{
Audiofile = audiofileMock.Object
Audiofile = new("Test.mp3", nameof(RecalculateLastTrackEnd_SingleTrackWithAudiofile_EndSetToAudiofileDuration), new AudioCodec("audio/mpeg", ".mp3", "AudioCodec MP3"), TimeSpan.FromMinutes(5))
};
var track1 = new Track { Position = 1, Begin = TimeSpan.Zero, End = TimeSpan.FromMinutes(2) };
var track2 = new Track { Position = 2, Begin = TimeSpan.FromMinutes(2) };
Expand Down
48 changes: 0 additions & 48 deletions AudioCuesheetEditor.Tests/Model/IO/Audio/AudiofileTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public async Task UploadFilesAsync_WithAudiofile_ImportsCorrectly()
_fileInputManagerMock.Setup(f => f.CheckFileMimeType(file.ContentType, file.Name, FileMimeTypes.Cuesheet, It.IsAny<IEnumerable<string>>())).Returns(false);
_fileInputManagerMock.Setup(f => f.IsValidForImportView(file.ContentType, file.Name)).Returns(false);
_fileInputManagerMock.Setup(f => f.IsValidAudiofile(file.ContentType, file.Name)).Returns(true);
_fileInputManagerMock.Setup(f => f.CreateAudiofileAsync(It.IsAny<FileUpload>(), It.IsAny<Action<Task<Stream>>?>())).ReturnsAsync(new AudioCuesheetEditor.Model.IO.Audio.Audiofile(file.Name));
_fileInputManagerMock.Setup(f => f.CreateAudiofileAsync(It.IsAny<FileUpload>())).ReturnsAsync(new Audiofile(file.Name));

IImportfile? sessionStateContainerImportfile = null;
_sessionStateContainerMock.SetupSet(x => x.Importfile = It.IsAny<IImportfile>()).Callback<IImportfile>(x => sessionStateContainerImportfile = x);
Expand Down
11 changes: 5 additions & 6 deletions AudioCuesheetEditor/AudioCuesheetEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@
<ItemGroup>
<PackageReference Include="HtmlSanitizer" Version="9.0.892" />
<PackageReference Include="MetaBrainz.MusicBrainz" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.5" PrivateAssets="all" />
<PackageReference Include="BlazorDownloadFile" Version="2.4.0.2" />
<PackageReference Include="Howler.Blazor" Version="0.10.0" />
<PackageReference Include="Markdig" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="10.0.4" />
<PackageReference Include="MudBlazor" Version="9.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="10.0.5" />
<PackageReference Include="MudBlazor" Version="9.2.0" />
<PackageReference Include="Toolbelt.Blazor.HotKeys2" Version="6.2.0" />
<PackageReference Include="z440.atl.core" Version="7.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
40 changes: 0 additions & 40 deletions AudioCuesheetEditor/Extensions/InterfaceConverter.cs

This file was deleted.

6 changes: 3 additions & 3 deletions AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Cuesheet() : Validateable, ITraceable, ICuesheet
private List<Track> tracks = [];
private String? artist;
private String? title;
private IAudiofile? audiofile;
private Audiofile? audiofile;
private CDTextfile? cDTextfile;
private String? catalogueNumber;
private readonly List<KeyValuePair<String, Track>> currentlyHandlingLinkedTrackPropertyChange = [];
Expand Down Expand Up @@ -89,7 +89,7 @@ public String? Title
FireEvents(previousValue, propertyName: nameof(Title));
}
}
public IAudiofile? Audiofile
public Audiofile? Audiofile
{
get => audiofile;
set
Expand Down Expand Up @@ -446,7 +446,7 @@ public override ValidationResult Validate(string property)

private void RecalculateTrackProperties(Track trackToCalculate)
{
if ((Audiofile != null) && (Audiofile.Duration.HasValue) && (trackToCalculate.End.HasValue == false))
if ((Audiofile?.Duration.HasValue == true) && (trackToCalculate.End.HasValue == false))
{
trackToCalculate.End = Audiofile.Duration;
}
Expand Down
60 changes: 3 additions & 57 deletions AudioCuesheetEditor/Model/IO/Audio/Audiofile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace AudioCuesheetEditor.Model.IO.Audio
{
[method: JsonConstructor]
public class Audiofile(String name) : IDisposable, IAudiofile
public class Audiofile(String name)
{
public static readonly AudioCodec AudioCodecWEBM = new("audio/webm", ".webm", "AudioCodec WEBM");

Expand All @@ -35,20 +35,17 @@ public class Audiofile(String name) : IDisposable, IAudiofile
];

private AudioCodec? audioCodec;
private Stream? contentStream;
private String name = name;
private bool disposedValue;

public event EventHandler? ContentStreamLoaded;

public Audiofile(String name, String objectURL, AudioCodec? audioCodec) : this(name)
public Audiofile(String name, String objectURL, AudioCodec? audioCodec, TimeSpan? duration = null) : this(name)
{
if (String.IsNullOrEmpty(objectURL))
{
throw new ArgumentNullException(nameof(objectURL));
}
ObjectURL = objectURL;
AudioCodec = audioCodec;
Duration = duration;
}

public String Name
Expand All @@ -71,32 +68,6 @@ public String Name
[JsonIgnore]
public String? ObjectURL { get; private set; }
/// <summary>
/// Boolean indicating if the stream has fully been loaded
/// </summary>
[JsonIgnore]
public Boolean IsContentStreamLoaded
{
get { return ContentStream != null; }
}
/// <summary>
/// File content stream. Be carefully, this stream is loaded asynchronously. Connect to the StreamLoaded for checking if loading has already been done!
/// </summary>
[JsonIgnore]
public Stream? ContentStream
{
get => contentStream;
set
{
contentStream = value;
if ((ContentStream != null) && (AudioCodec != null))
{
var track = new ATL.Track(ContentStream, AudioCodec.MimeType);
Duration = new TimeSpan(0, 0, track.Duration);
ContentStreamLoaded?.Invoke(this, EventArgs.Empty);
}
}
}
/// <summary>
/// Duration of the audio file
/// </summary>
public TimeSpan? Duration { get; private set; }
Expand Down Expand Up @@ -144,30 +115,5 @@ public Boolean PlaybackPossible
return playbackPossible;
}
}

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
if (ContentStream != null)
{
ContentStream.Close();
ContentStream.Dispose();
ContentStream = null;
}
}

disposedValue = true;
}
}

public void Dispose()
{
// Ändern Sie diesen Code nicht. Fügen Sie Bereinigungscode in der Methode "Dispose(bool disposing)" ein.
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}
31 changes: 0 additions & 31 deletions AudioCuesheetEditor/Model/IO/Audio/IAudiofile.cs

This file was deleted.

5 changes: 1 addition & 4 deletions AudioCuesheetEditor/Model/IO/Projectfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
//You should have received a copy of the GNU General Public License
//along with Foobar. If not, see
//<http: //www.gnu.org/licenses />.
using AudioCuesheetEditor.Extensions;
using AudioCuesheetEditor.Model.AudioCuesheet;
using AudioCuesheetEditor.Model.IO.Audio;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand All @@ -32,8 +30,7 @@ public class Projectfile(Cuesheet cuesheet)
ReferenceHandler = ReferenceHandler.IgnoreCycles,
Converters =
{
new JsonStringEnumConverter(),
new InterfaceConverter<IAudiofile, Audiofile>() // Add a custom converter for IAudiofile
new JsonStringEnumConverter()
}
};

Expand Down
4 changes: 2 additions & 2 deletions AudioCuesheetEditor/Services/Audio/PlaybackService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PlaybackService : IDisposable
private readonly IHowl _howl;

private int? soundId;
private IAudiofile? currentlyPlayingAudiofile;
private Audiofile? currentlyPlayingAudiofile;
private Timer? updateTimer;
private bool disposedValue;
private readonly Lock timerLock = new();
Expand Down Expand Up @@ -71,7 +71,7 @@ public PlaybackService(ISessionStateContainer sessionStateContainer, IHowl howl)
public async Task PlayOrPauseAsync()
{
//Reset if the last played audiofile is not the current one
if (currentlyPlayingAudiofile !=cuesheet.Audiofile)
if (currentlyPlayingAudiofile != cuesheet.Audiofile)
{
soundId = null;
}
Expand Down
Loading