我已经为我的应用项目设置了一个启动画面,并希望在启动画面加载后播放声音(mp3)。我是新手使用xcode,并想知道是否有人可以建议我需要输入什么代码/在哪里输入它..
非常感谢
答案 0 :(得分:0)
您在第一个视图控制器中实现了yourintrosound.wav系统声音,然后在加载视图控制器后立即使用appDelegate播放它:
你的firstViewController.h中的
@interface...
CFURLRef yourSound;
SystemSoundID soundFileObject;
@property (readwrite) CFURLRef yourSound;
@property SystemSoundID soundFileObject;
你的firstViewController.m viewDidLoad 中的
:didFinishLaunchingWithOptions: (刚刚[window makeKeyAndVisible]或你实施的任何闪屏显示) 并点击忘记AudioToolbox框架!
AppDelegate.m应用程序中的NSURL *rightSound = [[NSBundle mainBundle] URLForResource: @"yourintrosound" withExtension: @"wav"];
self.yourSound = (CFURLRef) [rightSound retain];
AudioServicesCreateSystemSoundID (yourSound, &soundFileObject);
[rightSound release];
AudioServicesPlaySystemSound (firstViewController.soundFileObject);