添加音频动画
This commit is contained in:
@@ -228,6 +228,7 @@
|
||||
|
||||
- (void)setInputState:(KBVoiceInputBarState)inputState {
|
||||
_inputState = inputState;
|
||||
NSLog(@"[KBVoiceInputBar] setInputState: %ld", (long)inputState);
|
||||
self.textInputView.hidden = (inputState != KBVoiceInputBarStateText);
|
||||
self.voiceInputView.hidden = (inputState != KBVoiceInputBarStateVoice);
|
||||
self.recordingView.hidden = (inputState != KBVoiceInputBarStateRecording);
|
||||
@@ -256,6 +257,7 @@
|
||||
[self.recordButton updateVolumeRMS:rms];
|
||||
if (self.inputState == KBVoiceInputBarStateRecording) {
|
||||
CGFloat safeRMS = MAX(rms, 0.6f);
|
||||
NSLog(@"[KBVoiceInputBar] updateVolumeRMS: %.3f (safe=%.3f)", rms, safeRMS);
|
||||
[self.leftWaveformView updateWithRMS:safeRMS];
|
||||
[self.rightWaveformView updateWithRMS:safeRMS];
|
||||
}
|
||||
@@ -533,6 +535,20 @@
|
||||
#pragma mark - Recording Wave
|
||||
|
||||
- (void)startRecordingWaveAnimationIfNeeded {
|
||||
NSLog(@"[KBVoiceInputBar] startRecordingWaveAnimationIfNeeded");
|
||||
self.leftWaveformView.hidden = NO;
|
||||
self.rightWaveformView.hidden = NO;
|
||||
[self.inputContainer setNeedsLayout];
|
||||
[self.recordingView setNeedsLayout];
|
||||
[self.inputContainer layoutIfNeeded];
|
||||
[self.recordingView layoutIfNeeded];
|
||||
[self.leftWaveformView setNeedsLayout];
|
||||
[self.rightWaveformView setNeedsLayout];
|
||||
[self.leftWaveformView layoutIfNeeded];
|
||||
[self.rightWaveformView layoutIfNeeded];
|
||||
NSLog(@"[KBVoiceInputBar] waveform frames L=%@ R=%@",
|
||||
NSStringFromCGRect(self.leftWaveformView.frame),
|
||||
NSStringFromCGRect(self.rightWaveformView.frame));
|
||||
[self.leftWaveformView startIdleAnimation];
|
||||
[self.rightWaveformView startIdleAnimation];
|
||||
[self.leftWaveformView updateWithRMS:0.7f];
|
||||
@@ -540,10 +556,13 @@
|
||||
}
|
||||
|
||||
- (void)stopRecordingWaveAnimation {
|
||||
NSLog(@"[KBVoiceInputBar] stopRecordingWaveAnimation");
|
||||
[self.leftWaveformView stopAnimation];
|
||||
[self.rightWaveformView stopAnimation];
|
||||
[self.leftWaveformView reset];
|
||||
[self.rightWaveformView reset];
|
||||
self.leftWaveformView.hidden = YES;
|
||||
self.rightWaveformView.hidden = YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user