こんにちは、オーディオを録音、再生、停止、上書きできるアプリを開発する必要があります。を使用して録音を行いましたAvAudioRecorder
:
NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100],AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey,
[NSNumber numberWithInt: 2],AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityLow], AVEncoderAudioQualityKey,
nil];
self.audioRecorder = [[AVAudioRecorder alloc]
initWithURL:audioFileURL
settings:audioSettings
error:nil];
[sliderTimer invalidate];
[self.audioRecorder record];
sliderTimer = [NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(updateSlider)
userInfo:nil repeats:YES];
...そして、再生は を使用して行われAVplayer
ます。
しかし、録音を上書きする方法がわかりません。これは私の上書き実装の概要です:
- 記録を停止
- スライダーの位置を特定のポイントに移動します
- その後、録音を開始します。
これは、以前の記録を上書きする機能です。
だから、私が書いた手順に従って
[self.audioRecorder stop];
[[self audioSlider] setValue:self.audioSlider.value animated:YES];
[self.audioRecorder recordAtTime:self.audioSlider.value forDuration:self.audioSlider.maximumValue];
...しかし、機能していません。代わりに、ファイルを完全に再記録します。この危機的な状況で私を助けてくれる人はいますか?