UILocalNotification:播放保存在文档目录中的自定义音频文件 [英] UILocalNotification: Playing a Custom Audio File saved in Documents Directory

查看:27
本文介绍了UILocalNotification:播放保存在文档目录中的自定义音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在创建一个警报应用程序,它可以播放来自服务器的自定义音频剪辑.我实现这一点的计划是将所有音频剪辑保存在本地,然后相应地设置 soundName.

但我有几个问题.目前,我在将音频文件保存在捆绑目录中时遇到了麻烦,并且只能将文件保存在文档目录中.是否可以从文档目录而不是包目录中设置 soundName ?
或者
我可以将音频文件从服务器保存到捆绑目录吗?

Currently I am creating an alarm app that plays custom audio clips from the server. My plan on implementing this is by saving all the audio clips locally and then setting the soundName accordingly.

But I am having a few issues. Currently I am having troubles saving the audio files in the bundle directory and only able to save the files in the document directory. Would it be possible to set the soundName from the document directory instead of the bundle directory?
OR
would it be possible for me to save the audio file from the server to the bundle directory?

var localNotification = UILocalNotification()
    localNotification.fireDate = self.timePicker.date
    localNotification.alertBody = "Alert Fired"
    localNotification.soundName = "fakesound.caf" // File saved in Document Directory
    UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

谢谢,如果您对我的问题有任何疑问,请告诉我.或者,如果您能想到关于我如何解决此问题的另一种解决方案.

Thanks, please let me know if you have any confusion with my question. Or if you can think of another solution on how I could solve this problem.

推荐答案

不幸的是,答案是否定的.

The answer, unfortunately, is no and no.

您只能在本地通知中播放捆绑包中的声音,并且捆绑包是只读的.

You can only play sounds from the bundle in a local notification, and the bundle is read-only.

您可以从本地通知播放的唯一声音必须随您的应用一起提供.没有其他选择.

The only sounds you can play from a local notification must be shipped with your app. No other option.

这篇关于UILocalNotification:播放保存在文档目录中的自定义音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆