How to add mp3 support with CFBundleTypeName
In applications like PDF Reader Lite, it's possible to associate PDF type with the app in such a way, when a PDF file will be opened in an app like Safari or Email, it will show an option to open the file in PDF Reader Lite app too.
Is it开发者_运维技巧 possible to implement similar thing for mp3? I have tried to add below tags in Info.plist file in below way.
<array>
<dict>
<key>CFBundleTypeName</key>
<string>MPG3</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.mp3</string>
</array>
</dict>
</array>
But when I open an mp3 URL (a URL having an extension .mp3 at end like this - http://sound18.mp3pk.com/indian/7khoonmaaf/7khoonmaaf01(www.songs.pk).mp3 it doesn't display the option to open the file in my app.
Will anyone please help me out for this?
Thanks,
It actually works if you set this dict to the CFBundleDocumentTypes key.
You can test if it works by sending a mail with a mp3 file to your iPhone or iPad. Hold down on the attachment and the UIDocumentInteractionController-View will pop up. Other applications can also use the UIDocumentInteractionController (see SDK documentation) to allow opening files with another app.
However, Mobile Safari doesn't do that for all media types. So it won't work when you open the URL directly.
An alternative would be to register an URL scheme for your app (CFBundleURLTypes), then you could pass the URL-String to the app through that custom URL scheme (myapp://www.example.com/file.mp3).
精彩评论