| | |
| | | #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 ESvideoVideoIntercomViewController ()<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; |
| | |
| | | NSString * refuseStr; |
| | | NSString * answerStr; |
| | | NSString * unlockSuccessfullyStr; |
| | | NSString * callingStr; |
| | | NSString * hangUpStr; |
| | | // int openDoorTimeout; |
| | | //全局变量 |
| | | SystemSoundID sound; |
| | |
| | | [self initTopBarView]; |
| | | [self initCentetView]; |
| | | [self initData]; |
| | | [self setAnswerBtnEnable:NO]; |
| | | // [self setAnswerBtnEnable:NO]; |
| | | [self initESVideo]; |
| | | //开始反呼 |
| | | [self StartReverseCall]; |
| | | [self ShowCalltimeBtn:callingStr]; |
| | | // Do any additional setup after loading the view. |
| | | } |
| | | |
| | |
| | | operationFailedStr = @"操作失败"; |
| | | refuseStr = @"拒绝"; |
| | | answerStr = @"接听"; |
| | | hangUpStr = @"挂断"; |
| | | unlockSuccessfullyStr = @"开锁成功"; |
| | | callingStr = @"来电中..."; |
| | | }else{ |
| | | tipStr = @"Prompt"; |
| | | okStr = @"OK"; |
| | |
| | | operationFailedStr = @"Operation failed."; |
| | | refuseStr = @"Refuse"; |
| | | answerStr = @"Answer"; |
| | | hangUpStr = @"Hang up"; |
| | | unlockSuccessfullyStr = @"Unlock successfully"; |
| | | callingStr = @"Incoming call"; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | UIView *TopView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, APP_TOP_BAR_HEIGHT)]; |
| | | TopView.backgroundColor = HEXCOLORA(0xF9F9F9,1.0); |
| | | // [TopView addSubview:self.backButton]; |
| | | [TopView addSubview:self.moreButton]; |
| | | // [TopView addSubview:self.moreButton]; |
| | | [self.view addSubview:TopView]; |
| | | TopView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.25].CGColor; |
| | | TopView.layer.shadowOffset = CGSizeMake(0,0.5); |
| | |
| | | -(void)backAction{ |
| | | [self.navigationController popViewControllerAnimated:true]; |
| | | // [self dismissViewControllerAnimated:YES completion:NULL]; |
| | | |
| | | } |
| | | |
| | | - (UIButton *)moreButton{ |
| | |
| | | |
| | | - (void)initCentetView { |
| | | [self.view addSubview:self.centerView]; |
| | | [self.centerView addSubview:self.collectButton]; |
| | | // [self.centerView addSubview:self.collectButton]; |
| | | [self.centerView addSubview:self.homeView]; |
| | | [self.centerView addSubview:self.unlockView]; |
| | | [self.unlockView addSubview:self.screenshotImgBtn]; |
| | |
| | | _centerView.backgroundColor = UIColor.whiteColor; |
| | | [self setRadiusWithView:_centerView]; |
| | | |
| | | _topUILabel= [[UILabel alloc] initWithFrame:CGRectMake(80, 20, APP_SCREEN_WIDTH-160, 24)]; |
| | | _topUILabel= [[UILabel alloc] initWithFrame:CGRectMake(80, GetRealHeight(20), APP_SCREEN_WIDTH-160, GetRealHeight(24))]; |
| | | _topUILabel.font = [UIFont fontWithName:APP_UIFont_BOLD size:15.0]; |
| | | _topUILabel.textColor = HEXCOLORA(0x333333, 1.0); |
| | | _topUILabel.text = @"二次确认机"; |
| | |
| | | |
| | | - (UIView *)homeView{ |
| | | if (_homeView == nil) { |
| | | _homeView = [[UIView alloc] initWithFrame:CGRectMake(0, 268, APP_SCREEN_WIDTH, 36)]; |
| | | _homeView = [[UIView alloc] initWithFrame:CGRectMake(0, GetRealHeight(268), APP_SCREEN_WIDTH, GetRealHeight(36))]; |
| | | _homeView.backgroundColor = HEXCOLORA(0x232323, 1.0); |
| | | UIImageView *mUIImageView= [[UIImageView alloc] initWithFrame:CGRectMake(20, 4, 28, 28)]; |
| | | UIImageView *mUIImageView= [[UIImageView alloc] initWithFrame:CGRectMake(GetRealWidth(20), GetRealHeight(4), GetRealHeight(28), GetRealHeight(28))]; |
| | | mUIImageView.image = [UIImage imageNamed:@"ic_esvideo_home"]; |
| | | [mUIImageView setContentMode:UIViewContentModeScaleAspectFit]; |
| | | [_homeView addSubview:mUIImageView]; |
| | |
| | | |
| | | - (UILabel *)homeUILabel{ |
| | | if (_homeUILabel == nil) { |
| | | _homeUILabel = [[UILabel alloc] initWithFrame:CGRectMake(52, 8, APP_SCREEN_WIDTH - 100, 20)]; |
| | | _homeUILabel = [[UILabel alloc] initWithFrame:CGRectMake(GetRealWidth(52), 0, APP_SCREEN_WIDTH - GetRealWidth(100), _homeView.frame.size.height)]; |
| | | _homeUILabel.font = [UIFont fontWithName:APP_UIFont size:12.0]; |
| | | _homeUILabel.textColor = [UIColor whiteColor]; |
| | | _homeUILabel.text = @"1栋203"; |
| | |
| | | |
| | | - (UIView *)unlockView{ |
| | | if (_unlockView == nil) { |
| | | _unlockView = [[UIView alloc] initWithFrame:CGRectMake(0, 304, APP_SCREEN_WIDTH, 48)]; |
| | | _unlockView = [[UIView alloc] initWithFrame:CGRectMake(0, GetRealHeight(304), APP_SCREEN_WIDTH, GetRealHeight(48))]; |
| | | _unlockView.backgroundColor = HEXCOLORA(0x232323, 1.0); |
| | | _unlockView.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor; |
| | | _unlockView.layer.shadowColor = [UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:0.4].CGColor; |
| | |
| | | |
| | | - (UIButton *)screenshotImgBtn{ |
| | | if (_screenshotImgBtn == nil) { |
| | | _screenshotImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(65, 6, 36, 36)]; |
| | | _screenshotImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(GetRealWidth(65), GetRealHeight(6), GetRealHeight(36), GetRealHeight(36))]; |
| | | [_screenshotImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_takephoto_unselect"] forState:UIControlStateNormal]; |
| | | // [_screenshotImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_takephoto_select"] forState:UIControlStateSelected]; |
| | | [_screenshotImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit]; |
| | |
| | | |
| | | - (UIButton *)unlockImgBtn{ |
| | | if (_unlockImgBtn == nil) { |
| | | _unlockImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(274, 6, 36, 36)]; |
| | | _unlockImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(APP_CONTENT_WIDTH-GetRealWidth(65)-GetRealHeight(36), GetRealHeight(6), GetRealHeight(36), GetRealHeight(36))]; |
| | | [_unlockImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_unlock_unselect"] forState:UIControlStateNormal]; |
| | | // [_unlockImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_unlock_select"] forState:UIControlStateSelected]; |
| | | [_unlockImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit]; |
| | |
| | | #pragma 挂断和开锁 |
| | | - (UIButton *)hangUpImgBtn{ |
| | | if (_hangUpImgBtn == nil) { |
| | | _hangUpImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(54, 448, 58, 58)]; |
| | | _hangUpImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(GetRealWidth(54), GetRealHeight(448), GetRealHeight(58), GetRealHeight(58))]; |
| | | [_hangUpImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_hangup"] forState:UIControlStateNormal]; |
| | | // [_hangUpImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_hangup"] forState:UIControlStateSelected]; |
| | | [_hangUpImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit]; |
| | |
| | | |
| | | - (UIButton *)hangUpTextBtn{ |
| | | if (_hangUpTextBtn == nil) { |
| | | _hangUpTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(33, 514, 100, 21)]; |
| | | _hangUpTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(33, 514, GetRealWidth(100), GetRealHeight(21))]; |
| | | [_hangUpTextBtn setTitle:@"拒绝" forState:UIControlStateNormal]; |
| | | _hangUpTextBtn.titleLabel.textAlignment = NSTextAlignmentCenter; |
| | | _hangUpTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:15.0]; |
| | | [_hangUpTextBtn setTitleColor:TextColor forState:UIControlStateNormal]; |
| | | [_hangUpTextBtn setTitleColor:TextSelectColor forState:UIControlStateSelected]; |
| | | [_hangUpTextBtn addTarget:self action:@selector(screenshotAction) forControlEvents:UIControlEventTouchUpInside]; |
| | | _hangUpTextBtn.center = CGPointMake(_hangUpImgBtn.center.x, GetRealHeight(525)); |
| | | |
| | | } |
| | | return _hangUpTextBtn; |
| | | } |
| | | |
| | | - (UIButton *)answerImgBtn{ |
| | | if (_answerImgBtn == nil) { |
| | | _answerImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(263, 448, 58, 58)]; |
| | | _answerImgBtn = [[UIButton alloc] initWithFrame:CGRectMake(APP_CONTENT_WIDTH-GetRealWidth(54)-GetRealHeight(58), GetRealHeight(448), GetRealHeight(58), GetRealHeight(58))]; |
| | | [_answerImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_answer"] forState:UIControlStateNormal]; |
| | | // [_answerImgBtn setImage:[UIImage imageNamed:@"ic_esvideo_answer"] forState:UIControlStateSelected]; |
| | | [_answerImgBtn.imageView setContentMode:UIViewContentModeScaleAspectFit]; |
| | |
| | | _answerTextBtn.hidden = YES; |
| | | |
| | | //挂断按钮移动中间 |
| | | _hangUpImgBtn.frame = CGRectMake(159, 448, 58, 58); |
| | | _hangUpTextBtn.frame = CGRectMake(138, 514, 100, 21); |
| | | // _hangUpImgBtn.frame = CGRectMake(159, 448, 58, 58); |
| | | // _hangUpTextBtn.frame = CGRectMake(138, 514, 100, 21); |
| | | _hangUpImgBtn.center = CGPointMake(APP_CONTENT_WIDTH/2, _hangUpImgBtn.center.y); |
| | | _hangUpTextBtn.center = CGPointMake(APP_CONTENT_WIDTH/2, _hangUpTextBtn.center.y); |
| | | |
| | | [_hangUpTextBtn setTitle:hangUpStr forState:UIControlStateNormal]; |
| | | //开始计时 |
| | | _callTimeout = 0; |
| | | [self startCountdown]; |
| | |
| | | |
| | | - (UIButton *)answerTextBtn{ |
| | | if (_answerTextBtn == nil) { |
| | | _answerTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, 514, 100, 21)]; |
| | | _answerTextBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, 514, GetRealWidth(100), GetRealHeight(21))]; |
| | | [_answerTextBtn setTitle:@"接听" forState:UIControlStateNormal]; |
| | | _answerTextBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:15.0]; |
| | | _answerTextBtn.titleLabel.textAlignment = NSTextAlignmentCenter; |
| | |
| | | [_answerTextBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled]; |
| | | [_answerTextBtn setTitleColor:TextSelectColor forState:UIControlStateSelected]; |
| | | [_answerTextBtn addTarget:self action:@selector(unlockAction) forControlEvents:UIControlEventTouchUpInside]; |
| | | _answerTextBtn.center = CGPointMake(_answerImgBtn.center.x, GetRealHeight(525)); |
| | | } |
| | | return _answerTextBtn; |
| | | } |
| | | |
| | | - (UIButton *)calltimeBtn{ |
| | | if (_calltimeBtn == nil) { |
| | | _calltimeBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, 382, 100, 30)]; |
| | | _calltimeBtn = [[UIButton alloc] initWithFrame:CGRectMake(242, GetRealHeight(382), GetRealWidth(100), GetRealHeight(30))]; |
| | | _calltimeBtn.backgroundColor = HEXCOLORA(0x000000, 0.4); |
| | | [_calltimeBtn setTitle:@"00:00" forState:UIControlStateNormal]; |
| | | _calltimeBtn.titleLabel.font = [UIFont fontWithName:APP_UIFont size:14.0]; |
| | | _calltimeBtn.titleLabel.textAlignment = NSTextAlignmentCenter; |
| | | [_calltimeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; |
| | | _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, 397); |
| | | _calltimeBtn.hidden = YES; |
| | | _calltimeBtn.layer.cornerRadius = 15; |
| | | _calltimeBtn.center = CGPointMake(APP_CONTENT_WIDTH/2, GetRealHeight(397)); |
| | | } |
| | | return _calltimeBtn; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | -(void)ShowTime:(int)nowTime { |
| | | if(_calltimeBtn.hidden) _calltimeBtn.hidden = NO; |
| | | NSString *timeStr = [self timeFormatted:nowTime]; |
| | | [self setCalltimeButtonText:timeStr]; |
| | | [self setCalltimeButtonText:timeStr isTime:YES]; |
| | | } |
| | | |
| | | -(void)ShowCalltimeBtn:(NSString*) mesStr { |
| | | if(_calltimeBtn.hidden) _calltimeBtn.hidden = NO; |
| | | |
| | | [self setCalltimeButtonText:mesStr isTime:NO]; |
| | | |
| | | |
| | | } |
| | | |
| | | /* |
| | | 根据文字调整按钮宽 |
| | | */ |
| | | -(void)setCalltimeButtonText:(NSString*) mesStr { |
| | | -(void)setCalltimeButtonText:(NSString*) mesStr isTime:(BOOL)isTime |
| | | { |
| | | [_calltimeBtn setTitle:mesStr forState:UIControlStateNormal]; |
| | | _calltimeBtn.frame = CGRectMake(0, 0, 100, 30); |
| | | _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, 397); |
| | | if(isTime){ |
| | | _calltimeBtn.frame = CGRectMake(0, 0, GetRealWidth(80), GetRealHeight(30)); |
| | | }else{ |
| | | _calltimeBtn.frame = CGRectMake(0, 0, GetRealWidth(115), GetRealHeight(30)); |
| | | } |
| | | _calltimeBtn.center = CGPointMake(APP_SCREEN_WIDTH/2, GetRealHeight(397)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | #pragma SDK可视对讲 功能部分 |
| | | -(void)initESVideo{ |
| | | _es = ESVideo.shareInstance.es; |
| | | //初始化中断,进入后台的tag |
| | | |
| | | |
| | | _playing = NO; |
| | | _isSpeaking = NO; |
| | | self.isInterrupt = NO; |
| | |
| | | }); |
| | | }; |
| | | //门口机会有视频的长宽高,是固定的(暂时还不确定) |
| | | _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback]; |
| | | // _es = [[ESVideoPhone alloc]initESVideoPhoneWithFrame:CGRectMake(0, 57, APP_SCREEN_WIDTH, 211) delegate:self imagecallBack:snapImageCallback]; |
| | | if (_es) { |
| | | //判断视频渲染是否初始化成功,如果失败会走ESVideoPhoneDelegate方法 |
| | | if (_es.showView) { |
| | | ESVideo.shareInstance.snapImageCallback = snapImageCallback; |
| | | _es.delegate = self; |
| | | _es.showView.backgroundColor = [UIColor whiteColor]; |
| | | [self.centerView addSubview:_es.showView]; |
| | | _es.showView.hidden = YES; |
| | | } |
| | | }else{ |
| | | NSLog(@"ESVideoPhone 初始化失败"); |
| | |
| | | return; |
| | | } |
| | | //初始化视频采集Capture |
| | | [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | if (isAccessVideo) { |
| | | if(![_es initVideoCaptureSession]){ |
| | | NSLog(@"VideoCaptureSession 初始化失败"); |
| | | } |
| | | } |
| | | //初始化AudioSession |
| | | _sessionHelper = [[AudioSessionHelper alloc]init]; |
| | | [_sessionHelper setAudioSession]; |
| | | // [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | // if (isAccessVideo) { |
| | | // if(![_es initVideoCaptureSession]){ |
| | | // NSLog(@"VideoCaptureSession 初始化失败"); |
| | | // } |
| | | // } |
| | | // //初始化AudioSession |
| | | // _sessionHelper = [[AudioSessionHelper alloc]init]; |
| | | // [_sessionHelper setAudioSession]; |
| | | //添加进入后台,中断等通知 |
| | | [self addObservers]; |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | -(void)showUIAlertViewWithBack:(NSString *)mes |
| | | { |
| | | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:mes preferredStyle:UIAlertControllerStyleAlert]; |
| | | [alertController addAction:[UIAlertAction actionWithTitle:okStr style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { |
| | | [self backAction]; |
| | | }]]; |
| | | |
| | | [self presentViewController:alertController animated:YES completion:nil]; |
| | | } |
| | | |
| | | |
| | | #pragma viewDidAppear |
| | | -(void)viewDidAppear:(BOOL)animated{ |
| | |
| | | //在viewDidLoad中 调用requestAccessForAVMediaType: 是为了节约初始化的时间 |
| | | //在viewDidAppear中调用requestAccessForAVMediaType: 是为了弹出提示打开权限的Alert |
| | | //测试的时候发现如下情况:如果只把授权方法放到ViewDidAppear方法中处理,如果没有授权在初始化采集器时会失败。同样AlertView会因为View没有didLoad而导致present不出来 |
| | | if (!isAccessVideo || !isAccessAudio) { |
| | | // if (!isAccessVideo || !isAccessAudio) { |
| | | // [self requestAccessForAVMedia]; |
| | | // } |
| | | // |
| | | if (!isAccessAudio) { |
| | | [self requestAccessForAVMedia]; |
| | | } |
| | | } |
| | |
| | | [_es stopTalk]; |
| | | |
| | | _es.delegate = nil; |
| | | |
| | | ESVideo.shareInstance.snapImageCallback = nil; |
| | | |
| | | |
| | | } |
| | | [_es freeSubClass]; |
| | | // [_es freeSubClass]; |
| | | } |
| | | -(void)dealloc{ |
| | | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| | |
| | | NSString *phoneEventStr = eventArray.lastObject; |
| | | |
| | | if([phoneEventStr isEqual:@"EVT_Ringing"]){ |
| | | _es.showView.hidden = NO; |
| | | //反呼成功 允许接听 看需求是否需要播放铃声和震动 |
| | | [self setAnswerBtnEnable:YES]; |
| | | |
| | |
| | | } else if([phoneEventStr isEqual:@"EVT_StopStream"]){ |
| | | // [_mCallOrAccept setTitle:@"反呼" forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_Connected"]){ |
| | | |
| | | // [_mCallOrAccept setTitle:@"通话中..." forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_HangUp"]){ |
| | | [self showUIAlertViewWithBack:@"已挂断"]; |
| | | // [_mCallOrAccept setTitle:@"反呼" forState:UIControlStateNormal]; |
| | | }else if([phoneEventStr isEqual:@"EVT_P2POnlineStatusChanged"]){ |
| | | //EVT_P2PStarted(p2p初始化OK,可以连接),EVT_P2POnlineStatusChangedonline=1 |
| | |
| | | NSString *result = nil; |
| | | //听筒状态 插耳塞后拔掉后恢复到默认设置 |
| | | if (sender == nil) { |
| | | result = [_sessionHelper speaker:NO]; |
| | | // result = [_sessionHelper speaker:NO]; |
| | | [_es resetAudioCaptureIsSpeak:NO]; |
| | | }else{ |
| | | if(!_isSpeaking){ |
| | | result = [_sessionHelper speaker:YES]; |
| | | // result = [_sessionHelper speaker:YES]; |
| | | [_es resetAudioCaptureIsSpeak:YES]; |
| | | _isSpeaking = YES; |
| | | }else{ |
| | | result = [_sessionHelper speaker:NO]; |
| | | // result = [_sessionHelper speaker:NO]; |
| | | [_es resetAudioCaptureIsSpeak:NO]; |
| | | _isSpeaking = NO; |
| | | } |
| | | } |
| | |
| | | |
| | | // 这里是考虑到用户没有授权,之后通过AlertAction跳转到设置页面授权后再回到APP时做的重新检测 |
| | | //跳转到设置页面,授权后返回页面,继续初始化采集器 |
| | | if (isAccessAudio && isAccessVideo) { |
| | | return; |
| | | } |
| | | if (isAccessVideo && !isAccessAudio) { |
| | | if(!isAccessAudio){ |
| | | [self requestAccessForAVMediaType:AVMediaTypeAudio]; |
| | | if (isAccessAudio) { |
| | | [_es initAudioCaptureSession]; |
| | | } |
| | | }else if (!isAccessVideo && isAccessAudio){ |
| | | [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | if (isAccessVideo) { |
| | | [_es initVideoCaptureSession]; |
| | | } |
| | | |
| | | }else if (!isAccessVideo && !isAccessAudio){ |
| | | [self requestAccessForAVMediaType:AVMediaTypeAudio]; |
| | | [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | if (isAccessAudio) { |
| | | [_es initAudioCaptureSession]; |
| | | } |
| | | if (isAccessVideo) { |
| | | [_es initVideoCaptureSession]; |
| | | } |
| | | } |
| | | |
| | | // if (isAccessAudio && isAccessVideo) { |
| | | // return; |
| | | // } |
| | | // if (isAccessVideo && !isAccessAudio) { |
| | | // [self requestAccessForAVMediaType:AVMediaTypeAudio]; |
| | | // if (isAccessAudio) { |
| | | // [_es initAudioCaptureSession]; |
| | | // } |
| | | // }else if (!isAccessVideo && isAccessAudio){ |
| | | //// [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | //// if (isAccessVideo) { |
| | | //// [_es initVideoCaptureSession]; |
| | | //// } |
| | | // |
| | | // }else if (!isAccessVideo && !isAccessAudio){ |
| | | // [self requestAccessForAVMediaType:AVMediaTypeAudio]; |
| | | //// [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | // if (isAccessAudio) { |
| | | // [_es initAudioCaptureSession]; |
| | | // } |
| | | //// if (isAccessVideo) { |
| | | //// [_es initVideoCaptureSession]; |
| | | //// } |
| | | // } |
| | | } |
| | | - (void)willEnterBackground:(NSNotification *)notification { |
| | | isBackGround = YES; |
| | |
| | | if (!isAccessAudio) { |
| | | [self requestAccessForAVMediaType:AVMediaTypeAudio]; |
| | | } |
| | | if (!isAccessVideo) { |
| | | [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | } |
| | | // if (!isAccessVideo) { |
| | | // [self requestAccessForAVMediaType:AVMediaTypeVideo]; |
| | | // } |
| | | if (!iSAudioNotDetermined && iSVideoNotDetermined){ |
| | | [self creatAlertViewWith:@"授权请求" message:@"麦克风没有授权,请在设置中开启权限,否则将影响通讯功能。" cancel:@"确定"]; |
| | | }else if(iSAudioNotDetermined && !iSVideoNotDetermined){ |