mpv icon indicating copy to clipboard operation
mpv copied to clipboard

osxbundle: refactor Information Property List

Open maxdunbar opened this issue 1 year ago • 9 comments

Replaces deprecated CFBundleTypeExtensions with LSItemContentTypes. LSHandlerRank ranks apps that declare as editors or viewers of a specific file type. Default value was chosen since mpv is a viewer of file types as opposed to an editor. I tested this patch with some filetypes (avi,mkv,mov,wav) and the launch service seemed to behave appropriately.

maxdunbar avatar Mar 18 '24 22:03 maxdunbar

i don't think CFBundleTypeExtensions and LSItemContentTypes are interchangeable. from the documentation former expects file extensions and the latter expects UTIs (all UTIs).

if we want to support file extensions that aren't defined by Apple we do need to define them and make them conform to one of the existing UTIs, eg with UTExportedTypeDeclarations and UTTypeConformsTo. probably similar to what we or VLC does.

Akemi avatar Mar 20 '24 18:03 Akemi

okay let get this a little bit sorted. lets start by cleaning up the CFBundleDocumentTypes and UTImportedTypeDeclarations node.

lets keep it to 3 different CFBundleDocumentTypes like currently, video, audio and subtitle files. though lets order them a bit different. the flat nodes at top and the collections/arrays at the bottom. for audio i would start with the general public.audio, video with public.video and public.movie and subtitles public.plain-text.

<dict>
    <key>CFBundleTypeIconFile</key>
    <string>document.icns</string>
    <key>CFBundleTypeName</key>
    <string>Audio file</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSTypeIsPackage</key>
    <false/>
    <key>NSPersistentStoreTypeKey</key>
    <string>Binary</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>UTI.URL.HERE</string>
        ...
    </array>
</dict>

after that we start to sort out the UTImportedTypeDeclarations node. ever entry should conform (UTTypeConformsTo node) to either public.audio, public.movie or public.plain-text depending on the type. take over, fill or extend the UTTypeIdentifier (UTI), UTTypeTagSpecification (with extension and mime-type declaration). any UTTypeIdentifier added here should be added to one of the three CFBundleDocumentTypes contained nodes (audio, video, subtitle) in the LSItemContentTypes array node. also lets try to sort those nodes, first all audio nodes, then all video node and at the bottom all subtitle nodes. all io.mpv.* UTIs should be replaces with the official UTIs, if possible and existent.

<dict>
    <key>UTTypeConformsTo</key>
    <array>
        <string>GENERAL.UTI.HERE</string>
    </array>
    <key>UTTypeDescription</key>
    <string>AC3 Audio</string>
    <key>UTTypeIconFile</key>
    <string>document.icns</string>
    <key>UTTypeIdentifier</key>
    <string>UTI.URL.HERE</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>public.filename-extension</key>
        <array>
            <string>EXTENSION</string>
            ...
        </array>
        <key>public.mime-type</key>
        <array>
            <string>MIME/TYPE</string>
            ...
        </array>
    </dict>
</dict>

lastly i would go through the list again and add all the other audio/video UTIs to the CFBundleDocumentTypes if they aren't already in some way in the UTImportedTypeDeclarations nodes.

References: UTIs: https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html Nodes: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685

Akemi avatar Mar 27 '24 19:03 Akemi

I reordered CFBundleDocumentTypes types to flat nodes at top and the collections/arrays at the bottom. There are still a few UTI's under LSItemContentTypes that I could not find. (I assume I will need to declare them as io.mpv.***. I also couldn't find public.mime-type for PCM HDV NUV HEVC YUV Y4M

maxdunbar avatar Apr 08 '24 02:04 maxdunbar

okay, i probably can't review your changes this week. it's a bit busy and i am not home at the weekend. just wanted to give you a heads up that i will try to look at everything as soon as possible.

Akemi avatar Apr 10 '24 19:04 Akemi

okay, i probably can't review your changes this week. it's a bit busy and i am not home at the weekend. just wanted to give you a heads up that i will try to look at everything as soon as possible.

Thanks, no rush!

maxdunbar avatar Apr 11 '24 01:04 maxdunbar

hope i've got everything.

Akemi avatar Apr 18 '24 21:04 Akemi

hope this will be the last batch of comments.

Akemi avatar May 18 '24 12:05 Akemi

only this one last thing. after this feel free to squash the commits and force push. then we can finally get this merged.

thank you for you hard work on this one, i really appreciate it.

Akemi avatar May 20 '24 14:05 Akemi