2011-11-15 6 views
0

録音オーディオをファイルに保存してAVAudioRecorderがいつ停止するかを知るには?

[[ AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error]; 

で指定されたファイルに何かレコーダーを停止し、正常にファイルを保存すると、すぐに録音したファイルを再生する必要があります。

質問はいつファイルを読み込んで再生するのがいいですか。どちらのデリゲートAPIを使用できますか?

答えて

0

あなたは

- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag 
{ 
    // Play the audio 
} 
1

を使用してみましたが、あなたのAVAudioRecorderインスタンスのデリゲート

AVAudioRecorder* test = [[AVAudioRecorder alloc] initWithURL:_fileURL settings:settings error:&_error]; 

が、その後

- (void) audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag 
{ 
    // play the recorded audio here 
    if (flag) 
    { 
     NSError* error; 
     AVAudioPlayer* player = [[[AVAudioPlayer alloc] initWithContentsOfURL:[recorder url] error:&error] autorelease]; 
     if (!error) 
     { 
      [player play]; 
     } 
    } 
} 
を実装設定しました
関連する問題