我正在尝试构建类似于当前在应用商店中的闹钟专业版和床头柜应用程序的闹钟。当闹铃时间到达时(通常是第二天早上),这些应用程序中的每一个都能够播放超过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