是否可以在启动画面之前/期间播放声音?
我的应用程序需要几秒钟才能加载,并且出现启动画面。一旦“viewDidLoad”我就会播放一些声音。我觉得如果在闪屏弹出时开始播放声音会更好。是否可以在启动画面之前/期间启动声音?
这是我的代码:(在 viewDidLoad 下)
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"intorSound" ofType: @"aif"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
[player setVolume: soundVolumeValue]; // available range is 0.0 through 1.0
[player play];
[fileURL release];
感谢您的时间!
My app takes a few seconds to load and I have a splash screen. Once "viewDidLoad" I have a little sound play. I feel that the sound would be in better use if it started playing when the splash screen popped up. Is it possible to have a sound start before/during the splash screen?
Here is my code: (under viewDidLoad)
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"intorSound" ofType: @"aif"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
[player setVolume: soundVolumeValue]; // available range is 0.0 through 1.0
[player play];
[fileURL release];
Thank you for your time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个小技巧是使用与 Default.png 相同的启动屏幕,无缝过渡到您控制的代码。当 applicationDidLaunch 被调用时,开始声音播放,并显示启动屏幕。如果需要,您也可以在启动屏幕上放置一个小进度指示器。在 viewDidLoad 中,完成所有初始化后,对闪屏进行 2-5 秒左右的淡入淡出。您可以输入代码,通过点击来关闭启动屏幕,从而给人们一些时间来阅读启动屏幕或点击它来关闭它。这一切都使得 Default.png 在没有声音的情况下显示的时间显得微不足道。
A little trick is to use the same splash screen as your Default.png, making a seamless transition into code you control. When applicationDidLaunch gets called, start your sound playback, and display the splash screen. If you want, you can put a little progress indicator up onto the splash screen as well. In viewDidLoad, when you are done with all initialization, do a 2-5 second or so fade of the splashscreen. You can throw in code to dismiss the splash screen with a tap, thus giving people some time to read the splash screen or tap it to dismiss it. This all makes the amount of time that the Default.png is displayed with no sound seem insignificant.
您可以显示自己的启动屏幕并在后台加载您的应用程序。这样,一旦 applicationDidLauch 完成,您就可以显示自己的启动屏幕和声音,然后在用户看到它时加载其余部分。
You can display your own splash screen and load your app in the background. This way, as soon as applicationDidLauch is done, you can display your own splash screen and sound, then load the rest while the user sees this.
我喜欢将启动屏幕保留更长的时间来播放声音的技术,但请注意,您正在混淆 HIG 指南,其中规定“避免显示“关于”窗口、启动屏幕或提供任何其他类型的启动体验,以阻止人们立即使用您的应用程序。” (第 45 页)
他们还详细讨论了第 45 页上的启动图像。 123 并强调它不应该建立你的品牌。然而,你总是看到这一点,有时它被称为“最常被打破的规则”——但要注意,你在它旁边跳舞有一条线。
I like the technique of leaving the splash screen up a little longer to play the sound, but beware you are messing with HIG guidelines which state "Avoid displaying an About window, a splash screen, or providing any other type of startup experience that prevents people from using your application immediately." (p. 45)
They also talk more about the startup image on p. 123 and stress it's NOT supposed to build your brand. However you see this all the time, and it is sometimes called the "most-often broken rule" - but beware there is a line you are dancing next to it.