如何使用本地通知播放录制的声音? [英] How can I play a recorded sound using a local notification?

查看:128
本文介绍了如何使用本地通知播放录制的声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,要求用户记录他们自己的消息,以便将来播放。我的意图是使用UILocalNotification来做到这一点。不幸的是,似乎与本地通知相关的声音必须存储在主包中,但用户无法进行录制并将其保存在包中。

I have an app that requires that the user record their own message to be played back at some future time. My intent was to do that using UILocalNotification. Unfortunately, it seems that the sound associated with the local notif has to be stored in the main bundle but the user cannot make a recording and save it in the bundle.

如何通过本地通知获取用户录制的声音文件?

How do I get a user recorded sound file to be played via local notification?

或者 - 如果应用程序没有运行以捕获本地通知(没有等待),有没有办法?让用户响应警报)然后播放所需的声音文件?

Alternatively - is there a way if the app is not running to capture the local notification (without waiting for the user to respond to an alert) and then play the desired soundfile?

谢谢!

推荐答案

您可以通过设置其属性,将(自定义)声音分配给 UILocalNotification

You can assign a (custom) sound to a UILocalNotification by setting its property as follows:

localNotification.soundName = @"MySoundFile.wav";

不幸的是,根据参考资料,不可能使用未存储的声音文件主要包或由apple声明:

Unfortunately, according to the reference, it is not possible to use a sound file that is not stored in the main bundle or is declared by apple:


对于此属性,请指定声源的文件名(包括扩展名)应用程序的主包或UILocalNotificationDefaultSoundName请求默认系统声音。

For this property, specify the filename (including extension) of a sound resource in the application’s main bundle or UILocalNotificationDefaultSoundName to request the default system sound.

另请参阅 UILocalNotification类参考#soundName

这篇关于如何使用本地通知播放录制的声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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