使用xcode中的启动画面添加声音加载

时间:2010-07-14 21:41:55

标签: xcode iphone-sdk-3.2 splash-screen

我已经为我的应用项目设置了一个启动画面,并希望在启动画面加载后播放声音(mp3)。我是新手使用xcode,并想知道是否有人可以建议我需要输入什么代码/在哪里输入它..

非常感谢

1 个答案:

答案 0 :(得分:0)

您在第一个视图控制器中实现了yourintrosound.wav系统声音,然后在加载视图控制器后立即使用appDelegate播放它:

你的firstViewController.h中的

@interface...

CFURLRef yourSound;
SystemSoundID   soundFileObject;

 @property (readwrite) CFURLRef yourSound;
 @property  SystemSoundID soundFileObject;
你的firstViewController.m viewDidLoad

中的

NSURL *rightSound   = [[NSBundle mainBundle] URLForResource: @"yourintrosound" withExtension: @"wav"];
self.yourSound = (CFURLRef) [rightSound retain];
AudioServicesCreateSystemSoundID (yourSound, &soundFileObject);
[rightSound release];
AppDelegate.m应用程序中的

:didFinishLaunchingWithOptions:

(刚刚[window makeKeyAndVisible]或你实施的任何闪屏显示)

 AudioServicesPlaySystemSound (firstViewController.soundFileObject);

并点击忘记AudioToolbox框架!