在iPhone中为启动画面添加声音

lak*_*esh 0 iphone audio

我想在iPhone的启动画面中添加一些背景音乐.我已经将启动画面时间增加了几秒钟..而且音乐时间不长......但我不知道该怎么做?需要一些指导......

Jan*_*mal 5

使用以下功能播放声音文件.

-(void)playSoundFromFileName:(NSString*)pstrFileName ofType:(NSString*)pstrFileType
{   
    SystemSoundID bell;
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:pstrFileName ofType:pstrFileType]], &bell);  
    AudioServicesPlaySystemSound (bell);    
}
Run Code Online (Sandbox Code Playgroud)

在应用程序委托中调用此函数didfinishlaunchingwithoptions方法...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{
     ...
     [self playSoundFromFileName:@"yourfile" ofType:@"extension"];

}
Run Code Online (Sandbox Code Playgroud)


jav*_*log 5

我的个人品味:不要打扰你的用户,尽可能快地摆脱困境