闹钟 iphone sdk 问题
这是一些代码。
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
if ([oldNotifications count] > 0) [app cancelAllLocalNotifications];
NSString *filePath = [DOCUMENTS stringByAppendingPathComponent:@"personal2.wav"];
//NSLog(@"%@",filePath);
//filePath = [[NSBundle mainBundle] pathForResource:@"wolf" ofType:@"wav"];
UILocalNotification *localNotif = [[UILocalNotification alloc]init];
localNotif.fireDate = alarmPicker.date ;
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Alarm";
localNotif.alertAction = @"View";
localNotif.soundName = filePath;
localNotif.applicationIconBadgeNumber = 1;
//localNotif.repeatInterval = NSYearCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
所以它只显示警报但不播放 wav。当我单击“查看”时,它会启动应用程序,并在 didReceiveLocalNotification 方法中再次播放这首歌,听起来不错。 有人可以帮我解决问题吗?谢谢
我读到 wav 的持续时间应该少于 30 秒,而它是 22 秒,所以它应该播放 PS2 是否有一种在本地通知启动时重复播放歌曲的方式。谢谢
Here is some code.
UIApplication *app = [UIApplication sharedApplication];
NSArray *oldNotifications = [app scheduledLocalNotifications];
if ([oldNotifications count] > 0) [app cancelAllLocalNotifications];
NSString *filePath = [DOCUMENTS stringByAppendingPathComponent:@"personal2.wav"];
//NSLog(@"%@",filePath);
//filePath = [[NSBundle mainBundle] pathForResource:@"wolf" ofType:@"wav"];
UILocalNotification *localNotif = [[UILocalNotification alloc]init];
localNotif.fireDate = alarmPicker.date ;
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Alarm";
localNotif.alertAction = @"View";
localNotif.soundName = filePath;
localNotif.applicationIconBadgeNumber = 1;
//localNotif.repeatInterval = NSYearCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
So it shows just alert but it is not playing wav. When i click View it starts the app and in didReceiveLocalNotification method i play this song again and it sounds good.
Can somebody help me with issue. Thanks
P.S. I read that duration of wav should be les than 30 sec and it is 22 seconds so it should play
P.S.2 Is it a way to repeat of playing the song when the localnotifications fires up. THANKS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您的应用目标属性中是否已在
必需的后台模式
下应用播放音频
。Check if you have
App plays audio
inRequired background modes
in your app's target properties.