如何使用本地通知播放录制的声音?

编程入门 行业动态 更新时间:2024-10-26 14:28:21
本文介绍了如何使用本地通知播放录制的声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个应用程序,要求用户记录他们自己的消息,以便将来播放。我的意图是使用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

更多推荐

如何使用本地通知播放录制的声音?

本文发布于:2023-11-27 01:57:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636098.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   声音   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!