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

编程入门 行业动态 更新时间:2024-10-27 08:28:44
本文介绍了如何在iTunes中设置来自歌曲的声音本地通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试创建闹钟应用但我不知道如何将iTunes中的歌曲设置为本地通知声音。

I try to create alarm app but I don't know how to set song from iTunes to sound of local notification.

现在我用这段代码来调用iTunes

Now I use this code to call 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]; }

关于本地通知的内容如下所示

and something about local notification look like this

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;

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

So please guide me how can I set song to local sound ??

推荐答案

您只能使用属于主要捆绑包的声音,这意味着,当提交到应用商店时,它们会在应用内置。

You can only use sounds that are a part of the main bundle, meaning, they have be in the build of the app when submitted to the app store.

是的,您可以在应用程序中录制声音,下载声音等,但这些声音创建/保存的文件都不能使用,因为它们不在应用程序的包中。如果应用程序通过在捆绑包外部访问它们来使用自定义声音,那么他们正在使用私有API来执行此操作。相信我,我已经尝试了我能想到的每一个选择。

Yes, you can record sound, download sound, etc in app, but none of those sounds files created/saved can be used, because they are not in the app's bundle. If an app is using custom sounds by accessing them outside of the bundle, then they are using private APIs to do so. Trust me, I've tried every option I can think of.

更多推荐

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

本文发布于:2023-11-27 02:00:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636107.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声音   通知   如何在   歌曲   iTunes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!