gpt4 book ai didi

ios - UILocalNotification 从应用文档播放声音

转载 作者:可可西里 更新时间:2023-11-01 04:44:46 25 4
gpt4 key购买 nike

我知道 UILocalNotification 仅支持应用程序包中的 soundName,但我看到程序在 Notification 中播放我录制的声音,即使程序已关闭。如何实现?任何想法对我来说都非常重要..

最佳答案

获取应用程序文档目录的 NSURL 的可靠方法是这样的......

NSURL *documentsDirectoryURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

然后你可以像这样获得对你的声音文件的 NSURL 引用......

NSURL *soundURL = [documentsDirectoryURL URLByAppendingPathComponent:@"sound.caf"];

如果您需要该 URL 处资源路径的字符串表示形式,您可以像这样获取它...

NSString *pathRepresentation = [soundURL absoluteString];

关于ios - UILocalNotification 从应用文档播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7904249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com