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

0002378

Suspended
Original poster
May 28, 2017
675
671
My app is an MP3 player. How do I program it to accept parameters, such as the path to an mp3 file or m3u playlist ?

In other words, what do I have to do in order to enable mp3 files, within Finder, to be opened with my app, by right-clicking and selecting "Open with (my app)" ?

Thanks.
 
Look at NSApplicationDelegate for the needed methods to implement in code.

As for telling Finder that your app can open files, the info.plist needs to be modified.
 
  • Like
Reactions: 0002378
Look at NSApplicationDelegate for the needed methods to implement in code.

Thanks ! Yes, it was far easier than I thought. I found the necessary methods there. Working like a charm !

As for telling Finder that your app can open files, the info.plist needs to be modified.

Can you provide more details here ? Thanks. Which key(s) in info.plist ?
EDIT: I looked at all the available keys in info.plist. I found 3 that might be applicable:
- Exported type UTIs
- Imported type UTIs
- URL types
 
CFBundleDocumentTypes (or "Document types") will tell Launch Services what files an app can open.

The UTIs will just offer a nice way to tell the system what your custom documents are. As your app uses mp3 files, you don't have to use those keys and you can just use the system-defined UTI for mp3s.
 
  • Like
Reactions: 0002378
CFBundleDocumentTypes (or "Document types") will tell Launch Services what files an app can open.

The UTIs will just offer a nice way to tell the system what your custom documents are. As your app uses mp3 files, you don't have to use those keys and you can just use the system-defined UTI for mp3s.

Thanks ! Yup, I looked it up on StackOverflow and it seems to be working with Document types.

I'm now adding all the other supported types (wav, aac, etc) as Document Types.

FYI, you probably know this, but it is easier to use the Project editor tool to add these document types than directly modifying the info.plist file.

In any case, thanks very much for your help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.