iOS 用のアプリを作成するのは初めてで、ストーリーボード モードを使用しています。サウンドを追加する方法を知りたかったのです。また、コーディングは必要ですか?
1 に答える
0
単純な音の再生に使用できます。AVFoundation
プロジェクトに AVFoundation を追加する必要があるフレームワークを使用し、#import <AVFoundation/AVFoundation.h>
- (IBAction) myPlayAction {
AVAudioPlayer *data;
NSString *name = [[NSString alloc] initWithFormat:@"SoundName"];
NSString *source = [[NSBundle mainBundle] pathForResource:name ofType:@"mp3"];
if (data) {
[data stop];
data = nil;
}
data=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: source] error:NULL];
data.delegate = self;
[data prepareToPlay];
[data play];
}
于 2012-05-13T04:25:51.497 に答える