Skip to content

Commit

Permalink
Handle InvalidChunkSizeException properly
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed May 23, 2021
1 parent 952c5a8 commit c247105
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion GenshinLyreMidiPlayer.Data/Midi/MidiFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public MidiFile(string path, ReadingSettings? settings = null)
_settings = settings;

Path = path;
InitializeMidi();
}

public int Position
Expand All @@ -24,12 +25,14 @@ public int Position
set => SetAndNotify(ref _position, value);
}

public Melanchall.DryWetMidi.Core.MidiFile Midi => Melanchall.DryWetMidi.Core.MidiFile.Read(Path, _settings);
public Melanchall.DryWetMidi.Core.MidiFile Midi { get; private set; }

public string Path { get; }

public string Title => GetFileNameWithoutExtension(Path);

public TimeSpan Duration => Midi.GetDuration<MetricTimeSpan>();

public void InitializeMidi() { Midi = Melanchall.DryWetMidi.Core.MidiFile.Read(Path, _settings); }
}
}
2 changes: 1 addition & 1 deletion GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<StartupObject>GenshinLyreMidiPlayer.WPF.App</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLyreMidiPlayer</RepositoryUrl>
Expand Down
3 changes: 3 additions & 0 deletions GenshinLyreMidiPlayer.WPF/ViewModels/LyrePlayerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ public double SongPosition
public async void Handle(MergeNotesNotification message)
{
if (!message.Merge)
{
Playlist.OpenedFile?.InitializeMidi();
InitializeTracks();
}

await InitializePlayback();
}
Expand Down

0 comments on commit c247105

Please sign in to comment.