我用從蘋果示例中的代碼從這個頁面: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