2011-07-20 4 views
0

私はiOS4のアプリケーションを書いています。コードからmp3ファイルをすばやく起動する方法はありますか?私は、アプリケーションが実行されている限り、mp3ファイルにループする必要があります。XCode4のコードからmp3を起動する方法

ありがとうございます。

+0

[自動的に繰り返し再生する]の複製が可能です(http://stackoverflow.com/questions/3560161/repeat-playing-automatically) –

答えて

2

はAVAudioPlayerを使用します。

NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"mp3"]; 
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc ] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 
audioPlayer.numberOfLoops = -1; // infinite loops 
[audioPlayer play]; 

これは仕事をしていません。

関連する問題