SKInCallViewController+time.m 973 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // SKInCallViewController+time.m
  3. // SikeyComm
  4. //
  5. // Created by 刘振兴 on 2025/2/14.
  6. // Copyright © 2025 BaH Cy. All rights reserved.
  7. //
  8. #import "SKInCallViewController+time.h"
  9. @implementation SKInCallViewController (time)
  10. - (void)startTimer {
  11. if (self.mTimer == nil) {
  12. self.mTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(talkingTimeCallback) userInfo:nil repeats:YES];
  13. }
  14. self.mTimecost = 0;
  15. }
  16. - (void)stopTimer {
  17. if (self.mTimer) {
  18. [self.mTimer invalidate];
  19. self.mTimer = nil;
  20. }
  21. }
  22. - (void)talkingTimeCallback {
  23. self.mTimecost++;
  24. self.mIngHeaderView.hidden = NO;
  25. JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
  26. self.mIngTimeLabel.text = [self formatTalkingTime:self.mTimecost];
  27. self.mIngNetWorkLabel.text = @"";
  28. }
  29. - (NSString *)formatTalkingTime:(long)time {
  30. return [NSString stringWithFormat:@"%02ld:%02ld", time/60, time%60];
  31. }
  32. @end