QuickLook on macOS: various questions

I'm trying to create a custom Quick Look preview on macOS. I've found the Quick Look Preview Extension target, which is brilliant, and does most of the 'heavy' lifting, but I've run into a few problems.

I'm implementing a preview for MIDI files (which has been missing since 2009...) using AVMIDIPlayer.

  1. The player keeps playing when the file is no longer selected! What's the mechanism for fixing that? Some sort of check that the view exists..?

  2. I notice that the OS preview for audio files has a different interface for the Finder's preview column and for the QuickLook 'pop-up' window. Again, I can't see how you define different views for those two environments.

Is there any documentation that's specifically "Mac"? I can only find iOS stuff. (Same for third-party tutorials.)

Accepted Reply

@benwiggy This was the only way I could reliably start and stop audio feedback.

viewWillDisappear is not called immediately when you navigate away from your file, it looks like the OS keeps 2-3 preview controllers active as you navigate between files.

Here's the workaround that seem to work on Ventura: https://stackoverflow.com/a/76433758/1182910

Replies

Ah: Number 1 is pretty straightforward, using the viewWillDisappear method, to add a stop command.

Still can't find anything about the 2nd question.

@benwiggy This was the only way I could reliably start and stop audio feedback.

viewWillDisappear is not called immediately when you navigate away from your file, it looks like the OS keeps 2-3 preview controllers active as you navigate between files.

Here's the workaround that seem to work on Ventura: https://stackoverflow.com/a/76433758/1182910