在 xcode 中添加声音以通过闪屏加载

发布于 2024-09-10 13:29:54 字数 107 浏览 1 评论 0原文

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

非常感谢

I have set up a splash screen for my app project and would like to have an sound (mp3) play just after the splash screen loads. I am new to using xcode and wondered whether some one could advise on what code I will need to input/where to input it..

Many Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧情勿念 2024-09-17 13:29:54

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

在您的firstViewController.h

@interface...

CFURLRef yourSound;
SystemSoundID   soundFileObject;

 @property (readwrite) CFURLRef yourSound;
 @property  SystemSoundID soundFileObject;

在您的firstViewController.m viewDidLoad< /em>

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 框架!

You implement a yourintrosound.wav system sound in the first view controller, then play it with the appDelegate just after the view controller is loaded:

in your firstViewController.h

@interface...

CFURLRef yourSound;
SystemSoundID   soundFileObject;

 @property (readwrite) CFURLRef yourSound;
 @property  SystemSoundID soundFileObject;

in your firstViewController.m viewDidLoad

NSURL *rightSound   = [[NSBundle mainBundle] URLForResource: @"yourintrosound" withExtension: @"wav"];
self.yourSound = (CFURLRef) [rightSound retain];
AudioServicesCreateSystemSoundID (yourSound, &soundFileObject);
[rightSound release];

in your AppDelegate.m application: didFinishLaunchingWithOptions:

(just after [window makeKeyAndVisible] or any splash screen display you implemented)

 AudioServicesPlaySystemSound (firstViewController.soundFileObject);

and do dot forget the AudioToolbox framework!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文