ボタンをクリックしたときにサウンドを再生しようとしています。サウンド クリップは 10 秒です。アプリケーションは正常に動作し、ボタンをクリックしても何も起こりません。エラーも何もありません。これが私のコードです。
.m file
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
- (IBAction)Play:(id)sender {
AVAudioPlayer *audioPlayer;
NSString *audioPath = [[NSBundle mainBundle]pathForResource:@"Blesgaes" ofType:@"mp3"];
NSURL *audioURL =[NSURL fileURLWithPath:audioPath];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:nil];
[audioPlayer play];
}
.h file
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController
- (IBAction)Play:(id)sender;
AVFoundation フレームワークを追加し、次の手順に従いました
http://looksok.wordpress.com/2013/01/19/ios-tutorial-play-sound/ http://www.techotopia.com/index.php/Playing_Audio_on_an_iPhone_using_AVAudioPlayer_(iOS_6) http://code-and- coffee.blogspot.in/2012/09/how-to-play-audio-in-ios.html
私が間違っていることについてのアイデア。