diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs index f9237e0..8eef58c 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs @@ -1,4 +1,4 @@ -// Copyright © 2024 QL-Win Contributors +// Copyright © 2017–2025 QL-Win Contributors // // This file is part of QuickLook program. // @@ -24,9 +24,7 @@ using System; using System.ComponentModel; using System.Globalization; using System.IO; -using System.Reflection; using System.Runtime.CompilerServices; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -56,8 +54,6 @@ internal class MidiPlayer : IDisposable, INotifyPropertyChanged } } - public event PropertyChangedEventHandler PropertyChanged; - public MidiPlayer(ViewerPanel panle, ContextObject context) { _vp = panle; @@ -76,7 +72,7 @@ internal class MidiPlayer : IDisposable, INotifyPropertyChanged _outputDevice = null; } - public void LoadAndPlay(string path, MediaInfoLib info) + public void LoadAndPlay(string path) { _midiFile = MidiFile.Read(path); _vp.metaTitle.Text = Path.GetFileName(path); @@ -200,13 +196,13 @@ internal class MidiPlayer : IDisposable, INotifyPropertyChanged } }; - // Playback supported by DryWetMidi will block the current thread - // So we should run it in a new thread - _ = Task.Run(() => _playback?.Play()); + _playback.Start(); _vp.buttonPlayPause.Content = FontSymbols.Pause; _context.IsBusy = false; } + public event PropertyChangedEventHandler PropertyChanged; + [NotifyPropertyChangedInvocator] protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs index 75ac689..89b6485 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs @@ -397,8 +397,8 @@ public partial class ViewerPanel : UserControl, IDisposable, INotifyPropertyChan if (audioCodec?.Equals("MIDI", StringComparison.OrdinalIgnoreCase) ?? false) { _midiPlayer = new MidiPlayer(this, _context); - _midiPlayer.LoadAndPlay(path, info); - return; // MIDI player will handle the playback at all + _midiPlayer.LoadAndPlay(path); + return; // Midi player will handle the playback at all } }