将音频和视频类型与iPhone应用程序相关联

时间:2012-07-17 13:38:13

标签: iphone ios5

我正在尝试制作一个应用程序,通过使用Long Press>从Mail应用程序接收媒体文件;在“我的应用”中打开

我无法将我想要的文件类型与我的应用相关联。我正在使用Uniform Type Identifiers Reference

这就是我的info.plist:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>mp3</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>MP3 Audio</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.mp3</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>avi</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>AVI movie</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.avi</string>
            <string>video/x-msvideo</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>3gp</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>3GPP movie</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.3gpp</string>
            <string>application/octet-stream</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>mpg4</string>
            <string>mp4</string>
            <string>m4v</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>MPEG-4 content</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.mpeg-4</string>
            <string>video/mp4</string>
            <string>video/mp4v</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>mov</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>QuickTime movie</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.apple.quicktime-movie</string>
            <string>video/quicktime</string>
        </array>
        <key>LSTypeIsPackage</key>
        <false/>
    </dict>
</array>

其中,只有Mp3和AVI显示“在我的应用程序中打开”选项。我刚刚收到“保存视频”选项,将视频添加到我的相机胶卷。我究竟做错了什么?

我想要关联的格式是:AVI,3GP,MP4,M4V,MOV。

我也试过这个。它适用于MP3,WAV,AVI,FLV,但仍然没有用于3GP,MP4,MOV,M4V

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Audio</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.audio</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Video</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.movie</string>
        </array>
    </dict>
</array>

2 个答案:

答案 0 :(得分:3)

How do I associate file types with an iPhone application?的回答,显示了一些与您的例子略有不同的例子。该文件的内容看起来应该有效,尽管根据文档有一些冗余:

  • CFBundleTypeExtensions仅为MacOS,即便如此,也是如此 如果LSItemContentTypes存在,则冗余并忽略。
  • LSTypeIsPackage仅为MacOS,即便如此,也是多余的 如果LSItemContentTypes存在,则忽略。
  • 文档建议使用统一类型标识符 CFBundleTypeName。例如对于mp4,而不是使用MPEG-4内容 如您所愿,请尝试public.mpeg-4(内部kUTTypeMPEG4)

仍然,虽然我认为清理是一个好主意,但我认为只有最后一个可能有解决问题的真正机会,因为其他两个应该被忽略。

...这意味着我认为实际上可以解决您的问题的方法是将您的应用从设备中清除并退出缓存,退出xcode,然后重新打开您的项目,重新构建并再次运行它。我遇到了一些问题,Xcode及其部署机制在设备上放置资源时会感到困惑。如果在你达到这一点之前最初的注册尝试失败了,那么执行这次清理工作可能会让事情变得很明朗。

答案 1 :(得分:0)

我已经安装了其他也支持文档导入的应用程序(例如TeamViewer,oPlayer等)。它们也没有出现在MOV,3GP,M4V等邮件应用程序的“Open As ..”操作表中。< / p>

我猜测苹果不允许第三方应用程序打开某些文件,并希望它们在内部处理。所以用户可以做的就是将它们保存到相机胶卷。

剩下的唯一选项是为我们的应用添加功能,以便从相机胶卷中选择视频。那么,邮件&gt;保存视频&gt;相机胶卷&gt;第三方应用程序

多么糟糕。

我在Info.plist中的最终条目

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Audio</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.audio</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>Video</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.3gpp</string>
            <string>public.3gpp2</string>
            <string>public.mpeg-4</string>
            <string>public.avi</string>
            <string>com.apple.quicktime-movie</string>
            <string>public.mpeg</string>
            <string>public.movie</string>
        </array>
    </dict>
</array>

我仍然希望有一些解决方法..任何人?