尝试在应用加载时播放声音
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//sleep(2);
[NSThread sleepForTimeInterval:2.0];
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"austinpowers", CFSTR("wav"), NULL);
if (soundFileURLRef) {
CFStringRef url = CFURLGetString(soundFileURLRef);
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
它会播放声音,但仅在加载墙纸(default.png)消失时才会播放。
如果有人可以帮助我,或为我指明正确的方向
谢谢
最佳答案
不要使用Default.png,而是创建您的自定义启动屏幕 View Controller ,您可以在其中显示图像并播放声音。
关于iphone - 应用加载时播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5189986/