gpt4 book ai didi

objective-c - 如何在 iTunes 中设置来自歌曲的声音本地通知?

转载 作者:可可西里 更新时间:2023-11-01 03:28:57 25 4
gpt4 key购买 nike

我尝试创建闹钟应用程序,但我不知道如何将 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;

所以请指导我如何将歌曲设置为本地声音??

最佳答案

您只能使用作为主包一部分的声音,这意味着,当提交到应用商店时,它们已经在应用的构建中。

是的,您可以在应用程序中录制声音、下载声音等,但是创建/保存的这些声音文件都不能使用,因为它们不在应用程序的 bundle 中。如果一个应用程序通过在 bundle 之外访问它们来使用自定义声音,那么他们正在使用私有(private) API 来这样做。相信我,我已经尝试了所有我能想到的选项。

关于objective-c - 如何在 iTunes 中设置来自歌曲的声音本地通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6894026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com