| | |
| | | #import <AVFoundation/AVFoundation.h> |
| | | #import <ESVideoPhoneSDk/ESVideoPhone.h> |
| | | #import <ESVideoPhoneSDk/ESError.h> |
| | | #import "AudioSessionHelper.h" |
| | | //#import "AudioSessionHelper.h" |
| | | #import <Photos/Photos.h> |
| | | #import <AudioToolbox/AudioToolbox.h> |
| | | #import "ESVideo.h" |
| | |
| | | |
| | | @interface ESOnIntercomViewController ()<ESVideoPhoneDelegate> |
| | | |
| | | @property (nonatomic,strong) AudioSessionHelper *sessionHelper; |
| | | //@property (nonatomic,strong) AudioSessionHelper *sessionHelper; |
| | | @property (nonatomic,strong) ESVideoPhone *es; |
| | | @property (nonatomic,assign) BOOL playing; |
| | | @property (nonatomic,assign) BOOL isInterrupt; |
| | |
| | | BOOL isBackGround; |
| | | BOOL iSVideoNotDetermined; |
| | | BOOL iSAudioNotDetermined; |
| | | BOOL isAnswer;//是否已经点击接听过了 |
| | | |
| | | NSString * tipStr; |
| | | NSString * okStr; |
| | |
| | | -(UILabel *)titleUILabel{ |
| | | if (_titleUILabel == Nil) { |
| | | _titleUILabel = [[UILabel alloc] initWithFrame:CGRectMake(90, APP_STATUS_BAR_HEIGHT, self.view.frame.size.width - 180, 44)]; |
| | | _titleUILabel.font = [UIFont fontWithName:APP_UIFont_BOLD size:17.0]; |
| | | _titleUILabel.font = [UIFont fontWithName:APP_UIFont_BOLD size:18.0]; |
| | | _titleUILabel.textColor = TextColor; |
| | | _titleUILabel.text = @""; |
| | | _titleUILabel.textAlignment = NSTextAlignmentCenter; |
| | |
| | | |
| | | //挂断按钮事件 |
| | | -(void)hangUpAction{ |
| | | //1.回调事件 |
| | | if(self.mESCallDelegate != NULL){ |
| | | if(isAnswer){ |
| | | //如果之前已经接听了,回调是挂断 |
| | | [self.mESCallDelegate onHangUpAction:_callTimeout]; |
| | | }else{ |
| | | //如果之前没接听了,回调是拒接 |
| | | [self.mESCallDelegate onRejectCallAction]; |
| | | } |
| | | } |
| | | //2.页面关闭 |
| | | [self backAction]; |
| | | } |
| | | |
| | |
| | | _hangUpTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, GetRealWidth(100), GetRealWidth(20))]; |
| | | [_hangUpTextBtn setTitle:@"拒绝" forState:UIControlStateNormal]; |
| | | _hangUpTextBtn.titleLabel.textAlignment = NSTextAlignmentCenter; |
| | | _hangUpTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:15.0]; |
| | | _hangUpTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:14.0]; |
| | | [_hangUpTextBtn setTitleColor:TextColor forState:UIControlStateNormal]; |
| | | [_hangUpTextBtn setTitleColor:TextSelectColor forState:UIControlStateSelected]; |
| | | [_hangUpTextBtn addTarget:self action:@selector(screenshotAction) forControlEvents:UIControlEventTouchUpInside]; |
| | |
| | | //开始计时 |
| | | _callTimeout = 0; |
| | | [self startCountdown]; |
| | | isAnswer = YES; |
| | | |
| | | if(self.mESCallDelegate != NULL){ |
| | | [self.mESCallDelegate onAnswerAction]; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | if (_answerTextBtn == nil) { |
| | | _answerTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, GetRealWidth(100), GetRealWidth(20))]; |
| | | [_answerTextBtn setTitle:@"接听" forState:UIControlStateNormal]; |
| | | _answerTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:15.0]; |
| | | _answerTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:14.0]; |
| | | _answerTextBtn.titleLabel.textAlignment = NSTextAlignmentCenter; |
| | | // _unlockTextBtn.titleLabel.textColor = TextColor; |
| | | [_answerTextBtn setTitleColor:TextColor forState:UIControlStateNormal]; |
| | |
| | | _openDoorTimeout = 0; |
| | | [self startOpenDoorCountdown]; |
| | | [self showUIAlertView:unlockSuccessfullyStr]; |
| | | |
| | | |
| | | // 开锁成功回调 |
| | | if(self.mESCallDelegate != NULL){ |
| | | [self.mESCallDelegate onUnlockAction]; |
| | | } |
| | | } |
| | | |
| | | -(void)setUnlock:(BOOL)ISEnable{ |
| | |
| | | // NSLog(@"VideoCaptureSession 初始化失败"); |
| | | // } |
| | | // } |
| | | //初始化AudioSession |
| | | _sessionHelper = [[AudioSessionHelper alloc]init]; |
| | | [_sessionHelper setAudioSession]; |
| | | // //初始化AudioSession |
| | | // _sessionHelper = [[AudioSessionHelper alloc]init]; |
| | | // [_sessionHelper setAudioSession]; |
| | | //添加进入后台,中断等通知 |
| | | [self addObservers]; |
| | | |
| | |
| | | // If media services were reset, and the last start succeeded, restart the session. |
| | | if (error.code == AVErrorMediaServicesWereReset) { |
| | | [_es onStopCapture]; |
| | | [_es startTalk]; |
| | | [_es stopTalk]; |
| | | } |
| | | } |
| | | |
| | |
| | | NSString *result = nil; |
| | | //听筒状态 插耳塞后拔掉后恢复到默认设置 |
| | | if (sender == nil) { |
| | | result = [_sessionHelper speaker:NO]; |
| | | // result = [_sessionHelper speaker:NO]; |
| | | [_es resetAudioCaptureIsSpeak:NO]; |
| | | }else{ |
| | | if(!_isSpeaking){ |
| | | result = [_sessionHelper speaker:YES]; |
| | | [_es resetAudioCaptureIsSpeak:YES]; |
| | | // result = [_sessionHelper speaker:YES]; |
| | | _isSpeaking = YES; |
| | | }else{ |
| | | result = [_sessionHelper speaker:NO]; |
| | | // result = [_sessionHelper speaker:NO]; |
| | | [_es resetAudioCaptureIsSpeak:NO]; |
| | | _isSpeaking = NO; |
| | | } |
| | | } |
| | |
| | | NSString *message = nil; |
| | | if (!error) { |
| | | message = saveToTheAlbumsStr; |
| | | // 截图成功回调 |
| | | if(self.mESCallDelegate != NULL){ |
| | | [self.mESCallDelegate onScreenshotSuccessfulAction:image]; |
| | | } |
| | | } |
| | | else |
| | | { |