// // IfishP2PLivePlayViewController.m // Ifish // // Created by imac on 16/11/11. // Copyright © 2016年 lianxiang. All rights reserved. // #import "IfishP2PLivePlayViewController.h" #import "IfishP2PVideoPlayView.h" #import "IfishSessionViewController.h" @interface IfishP2PLivePlayViewController () @end @implementation IfishP2PLivePlayViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self addTitleViewWithTitle:@"分享中"]; //自定义封装播放器 由于xib创建OPGLview 无法显示(暂未找到方法)暂时不用 纯代码建UI可以试试 //[self setupVideoPlayView]; //现采用继承ShopKanHuP2PViewController 替换底部 HbootmView // self.HbootmView.hidden= YES; self.view.backgroundColor = TABLE_BACKGROUD_COLOR; [self resetBootomView]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; } -(void)resetBootomView{ CGFloat playViewH= self.view.bounds.size.width * 9 / 16; P2PShareViewBootomView *bootomView = [[P2PShareViewBootomView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(self.canvasView.frame), self.view.frame.size.width,self.view.frame.size.height - playViewH)]; [bootomView initDataWithRoomId:self.listRoomInfo.room_id]; bootomView.roomModel = self.listRoomInfo; if (self.HbootmView) { [self.HbootmView removeFromSuperview]; } self.subHbottomView = bootomView; self.subHbottomView.delegate = self; [self.view addSubview:self.subHbottomView]; [self.view bringSubviewToFront:self.subHbottomView]; } //为用到 -(void)setupVideoPlayView{ IfishP2PVideoPlayView *playView=[IfishP2PVideoPlayView videoPlayView]; playView.delegate=self; // 播放器显示位置(竖屏时) playView.frame = CGRectMake(0,64, self.view.bounds.size.width, self.view.bounds.size.width * 9 / 16); [self.view addSubview:playView]; // 指定一个作为播放的控制器 playView.contrainerViewController = self; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)popularityAdd:(int)onLineP { NSLog(@"人气涨1"); // dispatch_async(dispatch_get_main_queue(), ^{ // [self.view makeToast:[NSString stringWithFormat:@"当前在线人数%d",onLineP]]; //}); //人气涨+ NSString *userId = [dataContorl dataControlGetUserIdInfo]; [AFHttpTool popularityValueRoomId:self.listRoomInfo.room_id userId:userId success:^(id response) { NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; if ([reDic[@"result"] isEqualToString:@"100"]) { NSString* popular = reDic[@"data"]; self.listRoomInfo.popularityValue = popular; [self.subHbottomView.tableView reloadData]; } } failure:^(NSError *err) { }]; } -(void)disHideSubControlerBootomm { self.subHbottomView.hidden= NO; } -(void)hideSubControlerBootomm { self.subHbottomView.hidden= YES; } #pragma mark -P2PShareViewBootomViewDelegate //聊天 -(void)chatBtnClickAction { UserModel*model=[dataContorl getUserInfo]; NSString *myAcount = [NSString stringWithFormat:@"%@",model.userId]; NSString *tarGetAcount = [NSString stringWithFormat:@"%@",self.listRoomInfo.userId]; if ([myAcount isEqualToString:tarGetAcount]) { [self.view makeToast:@"不能和自己聊天哦"]; return; } [[NIMSDK sharedSDK].loginManager login:myAcount token:model.neteaseToken completion:^(NSError *error) { if (!error) { NSLog(@"登录成功"); //创建session NIMSession *session = [NIMSession session:tarGetAcount type:NIMSessionTypeP2P]; //创建聊天页,这个页面继承自 NIMKit 中的组件 NIMSessionViewController self.hidesBottomBarWhenPushed = YES; IfishSessionViewController *vc = [[IfishSessionViewController alloc] initWithSession:session]; //vc.targetChatname = listmodel.nickName; [self stopP2PPlayingGLViewVideo]; [self.navigationController pushViewController:vc animated:YES]; }else{ NSLog(@"登录失败"); } }]; } #pragma mark- 暂停 挂断 -(void)stopP2PPlayingGLViewVideo{ if(!self.isReject){ self.isReject = !self.isReject; while (self.isPlaying) { usleep(50*1000); } [[P2PClient sharedClient] p2pHungUp]; self.remoteView.isQuitMonitorInterface = NO;//rtsp监控界面弹出修改 } } #pragma mark -已有人观看事件 -(void)alreadyHaveLookP { dispatch_async(dispatch_get_main_queue(), ^{ UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"当前有人正在观看,请稍后再来观看" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil]; [alert show]; }); } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { //取消 [self stopP2PPlayingGLViewVideo]; ///[self.remoteView getLastImgGoback]; [AppDelegate sharedDefault].canFullScreen = NO; [self.remoteView releseromotViewSet]; [self.navigationController popViewControllerAnimated:YES]; } @end