我用从苹果示例中的代码从这个页面:Link,但我似乎无法得到的声音重复。我检查了其他应用程序,例如Skype(VOIP)和Alarm Clock Pro(音频?),但无法重复播放声音文件。UILocalNotification重复声音
这是我的代码:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
AlarmHandler *AHinstance = getAlarmHandlerInstance();
UIApplication* app = [UIApplication sharedApplication];
NSArray *alarmList = [AHinstance getAlarms];
NSArray *oldNotifications = [app scheduledLocalNotifications];
if ([oldNotifications count] > 0)
{
[app cancelAllLocalNotifications];
}
for (Alarm *theAlarm in alarmList) {
NSDate *alarmDate = [theAlarm getNearestActivationDate];
Package *alarmPackage = [theAlarm getAlarmPackage];
NSArray *fileList = [alarmPackage getVoiceFileListForBackgroundNotificationWithHour:theAlarm.larmHour];
if(alarmDate == nil) continue;
UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
if (alarm)
{
NSLog(@"File: %@", [fileList objectAtIndex:0]);
alarm.fireDate = alarmDate;
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.soundName = [fileList objectAtIndex:0];
alarm.alertBody = @"Time to wake up!";
alarm.repeatInterval = 0;
[app scheduleLocalNotification:alarm];
}
}
}
我如何能解决这个问题有什么建议?
我曾建议注册应用为音频播放器和播放声音的背景,但似乎苹果并欣然接受这些应用程序,因为它们不是真正的音频播放器。因此他们否认这些应用程序。
问候,
保罗Peelen
伙计,你的应用程序现在完成...?实际上,我也面临同样的问题,即我的通知声音重复3次,因为我的声音是20秒。你可以帮我吗..?正如Itay说的那样,我发现它不可能, – mAc 2011-11-03 05:07:09
。您必须在一个文件中添加3次相同的声音,或者设置3个通知。 – 2011-11-03 08:40:40
@PaulPeelen你会得到任何解决方案? – Abha 2013-04-04 13:49:48