我使用了此页面中苹果示例的代码:Link,但我似乎无法让声音重复。我检查了其他应用程序,例如 Skype(用于 VOIP)和 Alarm Clock Pro(音频?),但我无法重复播放声音文件。
这是我的代码:
- (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];
}
}
}
关于如何解决这个问题有什么建议吗?
我曾建议将应用程序注册为音频播放器并在后台播放声音,但苹果似乎确实对这些应用程序很友好,因为它们不是真正的音频播放器。因此他们拒绝这些应用程序。
Regards,
保罗·皮伦
对于本地通知,无法执行此操作。您可以注册为 VOIP 应用程序或“背景音频”应用程序,它们具有单独的 API。但是,如果您没有提供适当的功能来满足这些用途,您很可能会被拒绝。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)