Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

benwiggy

macrumors 68020
Original poster
Jun 15, 2012
2,476
295
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.)
 
It's been some time since I played around with this, but does implementing the CancelPreviewGeneration callback not work?

Btw were you able to get the quicklook preview with the seek-bar interface? As far as I could see, there's no existing documentation for how to get a seekbar (unless you create one yourself with html, which would not look native), so maybe reverse-engineering is needed here.
 
I think I've sorted number 1: using viewWillDisappear function of the ViewController to stop it!

I've used a standard horizontal progress bar with a slider button, and linked the value to the duration. So you can slide it to any point and it plays from there.
 
  • Like
Reactions: f54da
Awesome - could you post your code somewhere? I've always wanted to fix up the qlvorbis (.ogg) plugin with progress bar support, but was limited by my scarce knowledge of the ui parts of cocoa.
 
You can see it here in this app that plays MIDI files. It's literally just a slider whose value is linked to the MIDI file's duration.


It's all in the ViewController. There's a timer that updates the time value, too.
 
Hm I thought quicklook plugins (at least using the public api) were limited to only drawing into a NSGraphicsContext though. I.e. you don't get to create your own views, the only thing a quicklook plugin can perform is either drawing to an NSGraphicsContext, or transforming the content type to something the OS can natively handle (via QLPreviewRequestSetDataRepresentation).


Although my knowledge here is about a decade out of date so maybe this restriction was loosened with the newer os.
 
The old QL plug-ins are deprecates: there's QuickLook Extensions now.
 
  • Like
Reactions: f54da
From my tests, that seems to produce preview icons for the files, rather than affecting the QL panel or popup.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.