我正在嘗試構建類似於當前在應用商店中的鬧鐘專業版和牀頭櫃應用程序的鬧鐘。當鬧鈴時間到達時(通常是第二天早上),這些應用程序中的每一個都能夠播放超過30秒鐘的鬧鐘聲。如何像鬧鐘專業版應用程序一樣播放超過30秒的鬧鐘聲音?
我已經試過兩種方法已經沒有運氣:
方法1:
[self performSelector:@selector(playAlarm) withObject:nil afterDelay:myDouble];
方法2:
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate =[datePicker date];//firedate;
notif.timeZone = [NSTimeZone systemTimeZone];
notif.alertBody = @"Time to wake up!";
NSString *SoundFileName=nil;
if([[[NSUserDefaults standardUserDefaults] objectForKey:@"ActualSoundFile"] isKindOfClass:[NSString class]])
SoundFileName=[[[NSString alloc]initWithString:[[NSUserDefaults standardUserDefaults]objectForKey:@"ActualSoundFile"]]autorelease];
else
SoundFileName=[[[NSString alloc] initWithString:@""] autorelease];
if([SoundFileName length]>1)
notif.soundName = [SoundFileName stringByAppendingString:@".wav"];
else
notif.soundName = UILocalNotificationDefaultSoundName;
[email protected]"Snooze";
notif.repeatCalendar=[NSCalendar currentCalendar];
notif.repeatInterval =NSDayCalendarUnit;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"Alarm" forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
有誰知道他們是怎麼能夠在7小時後在循環播放鬧鐘?
對於方法2,是所有的代碼?在一行之後你肯定需要更多的代碼。 –
@Ben - 剛剛添加了兩種方法。 – daSn0wie