我尝试创建闹钟应用程序,但我不知道如何将 iTunes 中的歌曲设置为本地通知的声音。
现在我使用此代码来调用 iTunes
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = NO;
picker.prompt = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some songs to play");
//[self presentModalViewController: picker animated: YES];
[self.navigationController pushViewController:picker animated:YES];
NSLog(@"gsudifghukdsf");
[picker release];
}
}
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
[self.navigationController popToRootViewControllerAnimated:YES];
//[self dismissModalViewControllerAnimated: YES];
NSLog(@"%@",mediaItemCollection);
UILocalNotification *local = [[UILocalNotification alloc] init];
//selectedSongCollection=mediaItemCollection;
}
- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
{
[self.navigationController popToRootViewControllerAnimated:YES];
//[self dismissModalViewControllerAnimated: YES];
}
关于本地通知的内容如下所示
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
{ //NSLog(@"Get in if localNotif");
return;
}
localNotif.fireDate = DateAlarm;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = [NSString stringWithFormat:@"%@",DateAlarm];
// Set the action button
localNotif.alertAction = @"Oh Shit";
localNotif.soundName = UILocalNotificationDefaultSoundName;
所以请指导我如何将歌曲设置为本地声音?
您只能使用主包中的声音,这意味着,当提交到应用程序商店时,它们已经存在于应用程序的构建中。
是的,您可以在应用程序中录制声音、下载声音等,但创建/保存的这些声音文件都不能使用,因为它们不在应用程序的捆绑包中。如果应用程序通过在捆绑包外部访问自定义声音来使用它们,则它们正在使用私有 API 来执行此操作。相信我,我已经尝试了所有我能想到的选择。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)