我正在尝试在我的应用程序中设置警报。我制作了UILocalNotification,它工作得很好。但我需要将一首mp3歌曲设置为通知的声音,但它不起作用
下面是一些代码
NSString *filePath = [DOCUMENTS stringByAppendingPathComponent:@"personal.mp3"];
//NSLog(@"%@",filePath);
UILocalNotification *localNotif = [[UILocalNotification alloc]init];
localNotif.fireDate = alarmPicker.date;
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Alarm";
localNotif.alertAction = @"View";
localNotif.soundName = filePath;
localNotif.applicationIconBadgeNumber = 1;
//localNotif.repeatInterval = NSYearCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];我应该添加框架还是应该做什么?现在它不能播放我的mp3。谢谢
发布于 2012-02-13 20:15:02
UILocation通知不支持.mp3这些是受支持的文件
由于自定义警报声音是由iOS系统声音工具播放的,因此它们必须采用以下音频数据格式之一:线性PCMMA4 (IMA/ADPCM)µLawaLaw
您可以将音频数据打包为aiff、wav或caf文件。然后,在Xcode中,将声音文件作为应用程序包的非本地化资源添加到项目中。
请参阅此问题的答案link
另请参阅此Preparing Custom Alert Sounds
编辑:为持续时间添加答案
您可以检查声音以确定其数据格式,方法是在QuickTime Player中打开声音,然后从“影片”菜单中选择“显示影片检查器”。
自定义声音播放时必须小于30秒。如果自定义声音超过该限制,则改为播放默认系统声音。
你可以使用音频编辑器/转换器来修剪你的歌曲
https://stackoverflow.com/questions/9260143
复制相似问题