huangxiaodong месяцев назад: 2
Родитель
Сommit
f3620f114f

+ 14 - 0
创维盒子/code/mine/recordViewController.m

@@ -47,6 +47,16 @@
     [self getRecordDataFun];
 }
 
+- (void)viewDidDisappear:(BOOL)animated
+{
+    [super viewDidDisappear:animated];
+    if (_progressTimer) {
+        [_progressTimer invalidate];
+        _progressTimer = nil;
+    }
+    
+}
+
 - (void)drawAnyView
 {
     [self.view setBackgroundColor:HWF5F7FAColor];
@@ -385,6 +395,10 @@
         return;
     }
     
+    if(_curAudioPlayer){
+        [self audioPlayerPauseFun];
+    }
+    
     //检测麦克风权限
     AVAudioSessionRecordPermission permissionStatus = [[AVAudioSession sharedInstance] recordPermission];
         

+ 30 - 24
创维盒子/code/mine/view/recordFileCell.m

@@ -339,31 +339,37 @@
     NSInteger playerMin = 0;
     NSInteger playerSecond = 0;
     
-    playerhour = _curRecordFileModel.curPlayerTime / 60 /60;
-    playerMin = (_curRecordFileModel.curPlayerTime  -60*playerhour)/60;
-    playerSecond = _curRecordFileModel.curPlayerTime  -60*playerhour - 60 *playerMin;
-    
-    NSString* playingTimeStr = [[NSString alloc] initWithFormat:@"%02ld:%02ld:%02ld",playerhour,playerMin,playerSecond];
-    
-    _progressingLabel.text  = playingTimeStr;
-    
-    CGFloat progress = _curRecordFileModel.curPlayerTime *1.0 /_curRecordFileModel.totalTime;
-    CGFloat BgWidth = _progressBgView.hw_w;
-    CGFloat progressingWidth = BgWidth* progress;
-    
-    [_progressingView mas_remakeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(0.f);
-        make.width.mas_equalTo(progressingWidth);
-        make.top.mas_equalTo(0);
-        make.height.mas_equalTo(2.f);
-    }];
+    if (_curRecordFileModel.curPlayerTime == 0) {
+        _progressingLabel.text = @"00:00:00";
+    }
+    else{
+        playerhour = _curRecordFileModel.curPlayerTime / 60 /60;
+        playerMin = (_curRecordFileModel.curPlayerTime  -60*playerhour)/60;
+        playerSecond = _curRecordFileModel.curPlayerTime  -60*playerhour - 60 *playerMin;
+        
+        NSString* playingTimeStr = [[NSString alloc] initWithFormat:@"%02ld:%02ld:%02ld",playerhour,playerMin,playerSecond];
+        
+        _progressingLabel.text  = playingTimeStr;
+        
+        CGFloat progress = _curRecordFileModel.curPlayerTime *1.0 /_curRecordFileModel.totalTime;
+        CGFloat BgWidth = _progressBgView.hw_w;
+        CGFloat progressingWidth = BgWidth* progress;
+        
+        [_progressingView mas_remakeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(0.f);
+            make.width.mas_equalTo(progressingWidth);
+            make.top.mas_equalTo(0);
+            make.height.mas_equalTo(2.f);
+        }];
+        
+        [_progressYuanView mas_remakeConstraints:^(MASConstraintMaker *make) {
+            make.left.equalTo(_progressingView.mas_right).offset(-2);
+            make.centerY.equalTo(_progressingView.mas_centerY);
+            make.width.mas_equalTo(6.f);
+            make.height.mas_equalTo(6.f);
+        }];
+    }
     
-    [_progressYuanView mas_remakeConstraints:^(MASConstraintMaker *make) {
-        make.left.equalTo(_progressingView.mas_right).offset(-2);
-        make.centerY.equalTo(_progressingView.mas_centerY);
-        make.width.mas_equalTo(6.f);
-        make.height.mas_equalTo(6.f);
-    }];
     
     if(curRecordFileModel.isEditType){
         checkButton.hidden = NO;

+ 49 - 5
创维盒子/code/mine/view/recordingView.m

@@ -12,6 +12,7 @@
 @property(nonatomic,strong)UILabel * timerlabel;
 @property(nonatomic,assign)NSInteger second;
 @property(nonatomic,strong)NSTimer * secondTimer;
+@property(nonatomic,strong)UIImageView *recordingTipImageView;
 @end
 
 @implementation recordingView
@@ -19,6 +20,7 @@
 - (id)initWithFrame:(CGRect)frame{
     self = [super initWithFrame:frame];
     
+    _second = 0;
     self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
     [self drawAnyView];
     
@@ -61,11 +63,11 @@
     }];
     
     //
-    UIImageView *recordingTipImageView = [[UIImageView alloc] init];
-    recordingTipImageView.image = [UIImage imageNamed:@"recording_tip"];
-    [whiteBgView addSubview:recordingTipImageView];
+    _recordingTipImageView = [[UIImageView alloc] init];
+    _recordingTipImageView.image = [UIImage imageNamed:@"recording_tip"];
+    [whiteBgView addSubview:_recordingTipImageView];
     
-    [recordingTipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
+    [_recordingTipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.width.mas_equalTo(323.f*AUTOSCALE);
         make.height.mas_equalTo(52.f*AUTOSCALE);
         make.centerX.mas_equalTo(0.f);
@@ -112,19 +114,61 @@
     //_secondTimer in
     _secondTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
     [[NSRunLoop currentRunLoop] addTimer:_secondTimer forMode:NSRunLoopCommonModes];
+    
+    [self startBreathingAnimationWithImageView:_recordingTipImageView];
 }
 
 #pragma mark 一秒一次的timer检测
 - (void)timerChange{
-   
+    _second +=1;
+    
+    KWeakSelf
+    mainBlock(^{
+        [weakSelf setTimeStringFun];
+    });
+    
+}
+
+#pragma mark 设置时间
+- (void)setTimeStringFun
+{
+    // 时长 totalTime
+    NSInteger hour = 0;
+    NSInteger min = 0;
+    NSInteger second = 0;
+    
+    hour = _second / 60 /60;
+    min = (_second  -60*hour)/60;
+    second = _second  -60*hour - 60 *min;
+    
+    NSString* totalTimeStr = [[NSString alloc] initWithFormat:@"%02ld:%02ld:%02ld",hour,min,second];
+    _timerlabel.text = totalTimeStr;
 }
 
 - (void)didClickButFun
 {
+    [self stopBreathingAnimationWithImageView:_recordingTipImageView];
+    [_secondTimer invalidate];
+    _secondTimer = nil;
+    
     [[AudioRecorderManager sharedManager] stopRecording];
     if (_didClickRecordEndFun) {
         _didClickRecordEndFun();
     }
 }
 
+- (void)startBreathingAnimationWithImageView:(UIImageView *)imageView {
+    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
+    animation.duration = 2.0;
+    animation.values = @[@1.0, @1.01, @1.02, @0.98, @1.0]; // 缩放值序列
+    animation.keyTimes = @[@0, @0.25, @0.5, @0.75, @1]; // 关键帧时间点
+    animation.repeatCount = HUGE_VALF;
+    
+    [imageView.layer addAnimation:animation forKey:@"keyframeScale"];
+}
+
+- (void)stopBreathingAnimationWithImageView:(UIImageView *)imageView
+{
+    [imageView.layer removeAllAnimations];
+}
 @end