4

I'm fairly new to iOS coming from Android. I'm having a bit of a hard time understanding the whole file and mime association deal. It is kinda confusing... I have searched all over for samples and I simply got more confused.

Essentially to get me started I want to support opening m3u playlists from browser, emails, and file browsers... on my app. The following information is what generally is seen for the m3u playlist.

Uri scheme
file or http

Mime
audio/x-mpegurl, audio/mpeg-url, application/x-winamp-playlist, audio/scpls, audio/x-scpls

File extension
.m3u with potential query at the end such as .m3u?id=21312312


UPDATE 1
File association seem to be working partially. Currently, clicking on any of the stations from the IceCast directory, they are opened by the browser. However, if I email my self the playlist file the email app is able to provide me with the option to open the playlist on my app.

Here is my updated plist file.

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>Playlists</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.vblast.xiialive.playlist</string>
            </array>
        </dict>
    </array>
<key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.url</string>
                <string>public.file-url</string>
                <string>public.filename-extension</string>
                <string>public.mime-type</string>
            </array>
            <key>UTTypeDescription</key>
            <string>Playlists</string>
            <key>UTTypeIdentifier</key>
            <string>com.vblast.xiialive.playlist</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>m3u</string>
                    <string>pls</string>
                    <string>asx</string>
                </array>
                <key>public.mime-type</key>
                <array>
                    <string>audio/playlist</string>
                    <string>audio/mpegurl</string>
                    <string>audio/x-mpegurl</string>
                    <string>audio/m3u</string>
                    <string>x-winamp-playlist</string>
                    <string>application/x-winamp-playlist</string>
                    <string>audio/x-scpls</string>
                    <string>video/x-ms-asf</string>
                </array>
            </dict>
        </dict>
    </array>
Jona
  • 13,325
  • 15
  • 86
  • 129
  • Seems odd to me that its using public.audio for a m3u file. Shouldn't it be: public.text and public.playlist? Also, can you post any errors, or confirm you are not getting any? – Logham Sep 22 '14 at 09:14
  • I'm not seeing any errors. The browser is just opening the file and trying to play it.... :/ I have tried adding public.text and public.playlist but no difference. I'm definitely no understanding something about Document Types and Exported UTIs. Maybe I need some type of generic open all file types to get started. – Jona Sep 22 '14 at 13:46
  • I don't think there is a way to prevent safari from automatically opening any file it can, and in the case of movies and videos it won't give you the option to play them in another app. The best solution that I can think of would be creating a safari share sheet plugin that when activated would scan the page for any .m3u links and change them all to a custom link that opens your app. – TyloBedo Sep 29 '14 at 02:41

1 Answers1

0

Your browser is most likely opening the .m3u files itself because it can, however your mail client can't so it'll bring up a list of possible associated applications. Which is where your app comes up.

However you can try implementing this code in your html file using jQuery

$(document).ready(function() {
    var user_agent_header = navigator.userAgent;

    if(user_agent_header.indexOf('iPhone')!=-1 || user_agent_header.indexOf('iPod')!=-1 || user_agent_header.indexOf('iPad')!=-1){
        setTimeout(function() { window.location="playlistApp://www.mydomain.com/files/myplaylist.m3u";}, 25);
    }

});

Code taken from How to open iOS app from browser?

Community
  • 1
  • 1
Quill
  • 2,729
  • 1
  • 33
  • 44
  • Thanks for writing an answer. Unfortunately, I'm not looking for a webpage solution since I'm not the owner of any of these radio stations. I'm simply trying to tell the OS I can play them and to send them over to my app... – Jona Sep 30 '14 at 17:04