// // YOUPAILCVideoRequestVC.m // LiveChat // // Created by 张灿 on 2018/9/17. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCVideoRequestVC.h" #import "YOUPAILCRequestView.h" @interface YOUPAILCVideoRequestVC () @property(nonatomic,strong)YOUPAILCRequestView* youpaiprequestView; @end @implementation YOUPAILCVideoRequestVC - (void)viewDidLoad{ [super viewDidLoad]; [self youpaifsetupResquestView]; } - (void)youpaifsetupResquestView{ self.youpaiprequestView = [[YOUPAILCRequestView alloc]initWithModel:self.youpaipvideoModel]; self.youpaiprequestView.youpaipdelegate = self; [self.view addSubview:self.youpaiprequestView]; } - (void)youpaifcloseRequestBtnClick{ [self videoEnd:7]; } - (void)youpaifcancelBtnClick{ //点击了取消按钮 [self.youpaipsocketManager sendCancel]; } //-(void)timeOver //{ // [self videoEnd:3]; //} - (void)requestSuccess{ //主叫连接成功 self.youpaiprequestView.youpaipcancelBtn.hidden = NO; self.youpaiprequestView.youpaiptimeLabel.hidden = NO; self.youpaiprequestView.youpaipcloseBtn.hidden = YES; [self.youpaiprequestView youpaiftimePadding]; NSDictionary* dictData = @{@"id":@11, @"data":@{ @"roomid":self.youpaipvideoModel.youpaiproom_id, @"callTime":[LCTools getCurrentTimestamp] } }; NSString* str = [dictData mj_JSONString]; NSLog(@"mj_JSONString = %@",str); NIMCustomSystemNotificationSetting *set = [[NIMCustomSystemNotificationSetting alloc]init]; set.shouldBeCounted = NO; NIMCustomSystemNotification* customSysNotification = [[NIMCustomSystemNotification alloc]initWithContent:str]; customSysNotification.apnsPayload = @{ @"sound":@"open.wav", @"callType":@"video" }; customSysNotification.apnsContent = @"收到视频请求"; customSysNotification.sendToOnlineUsersOnly = NO; customSysNotification.setting = set; [[NIMSDK sharedSDK].systemNotificationManager sendCustomNotification:customSysNotification toSession:[NIMSession session:self.youpaipvideoModel.youpaipto_uid type:(NIMSessionTypeP2P)] completion:^(NSError * _Nullable error) { }]; } - (void)responseChoosing:(NSString*)tip{ //被叫连接成功 self.youpaiprequestView.youpaiptipLabel.text = tip; } //add by leo 剩余可通话时间 - (void)canCallTime:(NSString*)tip { dispatch_async(dispatch_get_main_queue(), ^{ NSString *callTimeStr = [NSString stringWithFormat:@"剩余时长:%@",[ZCUtils getHHMMSSFromSS:tip.integerValue]]; // NSLog(@"tip.integerValue is %ld\n",tip.integerValue); if(tip.integerValue <= 1) { //剩余时间不足 主动挂断 NSLog(@"费用不足发送了一次挂断信息\n"); [self.youpaipsocketManager sendHangup]; } [self.youpaipcancallTimeLab setText:callTimeStr]; }); } // 已减免时长 - (void)discountWithTime:(NSInteger)time{ dispatch_async(dispatch_get_main_queue(), ^{ if (time <= 0) { self.youpaipformDiscountBgV.hidden = YES; }else{ self.youpaipformDiscountBgV.hidden = NO; self.youpaipformDiscountL.text = [NSString stringWithFormat:@" 已减免%@分钟 ",@(time)]; } }); } - (void)videoStart:(NSDictionary*)dict{ //视频开始 [super videoStart:dict]; [UMengRecordTool umengEventCountWithId:TurnOnTheVideo]; self.view.backgroundColor = [UIColor blackColor]; [self youpaifsetupInterView]; if (self.youpaiprequestView.youpaiptimer) { dispatch_source_cancel(self.youpaiprequestView.youpaiptimer);//删除GCD定时器 self.youpaiprequestView.youpaiptimer = nil; } [self.youpaiprequestView removeFromSuperview]; } //1主动取消 2。拒绝 3.超时 4.被叫者挂断 5.主叫者挂断 6.费用不足 - (void)videoEnd:(NSInteger)type{ [super videoEnd:type]; if (type==1) { [ZCHUDHelper showTitle:@"已取消"]; }else if (type==2){ [ZCHUDHelper showTitle:@"已拒绝"]; }else if (type==3){ [ZCHUDHelper showTitle:@"超时无应答"]; }else if (type==4){ [ZCHUDHelper showTitle:@"对方已挂断"]; }else if (type==5){ [ZCHUDHelper showTitle:@"通话已结束"]; }else if (type==6){ [ZCHUDHelper showTitle:@"费用不足已断开"]; }else if (type==10){ [ZCHUDHelper showTitle:@"检测到本次视频违规,请遵守平台相关规则" showtime:5]; }else if (type==11){ [ZCHUDHelper showTitle:@"检测到本次视频违规,请遵守平台相关规则" showtime:5]; } } - (void)youpaifsetupInterView{ [super youpaifsetupInterView]; } @end