如何将背景声音添加到iPhone应用程序
在这里你去:
声音添加到您的资源文件夹在Xcode,然后不管你想要的声音播放此代码添加到您的代码。 (在一个按钮点击例如方法)
NSString *path = [[NSBundle mainBundle]pathForResource:@"NameOfSoundfile" ofType:@"mp3"];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer play];
谢谢你的帮助。为了我的理解,我把这段代码放在applicationDidFinishLaunching附近的Appdelegate.m中?我不需要一个按钮。 – user1322754 2012-04-15 10:42:21
是的,你可以把它放在applicationDidFinishLaunching或者applicationDidBecomeActive中。 – EricS 2012-04-15 14:32:55
@EricS说什么。 – 2012-04-15 16:17:24
http://stackoverflow.com/questions/1973902/play-mp3-files-with-iphone-sdk – tipycalFlow 2012-04-15 10:18:23
https://www.google.co.in/search?sourceid = chrome&ie = UTF-8&q = ios + play + audio +文件 – tipycalFlow 2012-04-15 10:18:40