Skip to content

Commit 4038cf2

Browse files
committed
Fix MIDI player ShouldLoop not togglable
1 parent a1cd8a1 commit 4038cf2

File tree

1 file changed

+1
-10
lines changed
  • QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack

1 file changed

+1
-10
lines changed

QuickLook.Plugin/QuickLook.Plugin.VideoViewer/AudioTrack/MidiPlayer.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using Melanchall.DryWetMidi.Interaction;
2020
using Melanchall.DryWetMidi.Multimedia;
2121
using QuickLook.Common.Annotations;
22-
using QuickLook.Common.Helpers;
2322
using QuickLook.Common.Plugin;
2423
using System;
2524
using System.ComponentModel;
@@ -43,7 +42,6 @@ internal class MidiPlayer : IDisposable, INotifyPropertyChanged
4342
private OutputDevice _outputDevice;
4443
private Playback _playback;
4544
private TimeSpan _duration;
46-
private MethodInfo _setShouldLoop; // Reflection to invoke `_vp.set_ShouldLoop()`
4745

4846
private long _currentTicks = 0L;
4947

@@ -64,6 +62,7 @@ public MidiPlayer(ViewerPanel panle, ContextObject context)
6462
{
6563
_vp = panle;
6664
_context = context;
65+
_outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth");
6766
}
6867

6968
public void Dispose()
@@ -84,7 +83,6 @@ public void LoadAndPlay(string path, MediaInfoLib info)
8483
_vp.metaArtists.Text = _midiFile.OriginalFormat.ToString();
8584
_vp.metaAlbum.Text = _midiFile.TimeDivision.ToString();
8685

87-
_outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth");
8886
_playback = _midiFile.GetPlayback(_outputDevice);
8987

9088
if (_playback.GetDuration(TimeSpanType.Metric) is MetricTimeSpan metricTimeSpan)
@@ -123,15 +121,8 @@ public void LoadAndPlay(string path, MediaInfoLib info)
123121
}
124122
};
125123

126-
if (_vp.GetType().GetProperty("ShouldLoop", BindingFlags.Instance | BindingFlags.Public) is PropertyInfo propertyShouldLoop)
127-
{
128-
_setShouldLoop = propertyShouldLoop.GetSetMethod(nonPublic: true);
129-
_setShouldLoop.Invoke(_vp, [SettingHelper.Get("ShouldLoop", false, "QuickLook.Plugin.VideoViewer")]);
130-
}
131-
132124
_vp.buttonLoop.Click += (_, _) =>
133125
{
134-
_setShouldLoop.Invoke(_vp, [!_vp.ShouldLoop]);
135126
_playback.Loop = _vp.ShouldLoop;
136127
};
137128

0 commit comments

Comments
 (0)