124 lines
3.7 KiB
Objective-C
124 lines
3.7 KiB
Objective-C
//
|
|
// PlayBackViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by 祝发冬 on 2020/10/18.
|
|
// Copyright © 2020 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "PlayBackViewController.h"
|
|
|
|
@interface PlayBackViewController ()<GWP2PPlayerProtocol>
|
|
@property (nonatomic, strong) GWP2PPlaybackPlayer *player;//摄像头页面
|
|
@property (nonatomic) BOOL isReject;
|
|
@end
|
|
|
|
@implementation PlayBackViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
// formatter.dateFormat = @"yyyy-MM-dd HH:mm";
|
|
//
|
|
// NSString *string = [formatter stringFromDate:self.model.date]; //
|
|
|
|
[self setTitleString:@"视频回放"];
|
|
self.view.backgroundColor=[UIColor lightGrayColor];
|
|
[self connectDevice];
|
|
|
|
// Do any additional setup after loading the view from its nib.
|
|
}
|
|
-(void)playFiles
|
|
{
|
|
//添加播放器VC
|
|
|
|
self.player = [[GWP2PPlaybackPlayer alloc] init];
|
|
|
|
self.player.mute = YES;
|
|
self.player.delegate=self;
|
|
self.player.viewController.view.backgroundColor = [UIColor clearColor];
|
|
|
|
self.player.viewController.view.frame=self.playView.bounds;
|
|
[self addChildViewController:self.player.viewController];
|
|
[self.playView addSubview:self.player.viewController.view];
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
WEAK_SELF;
|
|
[self.player p2pCallPlaybackFileWithDeviceId:self.camera.cameraId password:self.camera.cameraPass playbackFile:self.model calling:^(NSDictionary *parameters) {
|
|
|
|
} accept:^(NSDictionary *parameters) {
|
|
|
|
} reject:^(GWP2PCallError error, NSString *errorCode) {
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
|
|
[weakSelf.view makeToast:@"连接失败请重试!"];
|
|
|
|
weakSelf.retryBtn.hidden=NO;
|
|
});
|
|
|
|
|
|
} ready:^{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
[MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
|
|
|
|
weakSelf.retryBtn.hidden=YES;
|
|
});
|
|
}] ;
|
|
|
|
;
|
|
|
|
}
|
|
|
|
-(void)connectDevice{
|
|
|
|
UserModel *model=[dataContorl getUserInfo];
|
|
NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff];
|
|
//初始化设备
|
|
if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) {
|
|
NSLog(@"正在检查P2P连接状态");
|
|
BOOL connectDevice = [[GWP2PClient sharedClient] connectWithAccount:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil];
|
|
|
|
if (connectDevice) {
|
|
|
|
[self playFiles];
|
|
|
|
}else{
|
|
[self retry:nil];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
[self playFiles];
|
|
}
|
|
|
|
}
|
|
-(BOOL)p2pPlayer:(GWP2PPlayer *)player shouldHandlerSwipeGesture:(UIGestureRecognizer *)gesture
|
|
{
|
|
return YES;;
|
|
}
|
|
-(void)goBackAction{
|
|
|
|
[self.player p2pPause];
|
|
self.player=nil;
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
- (IBAction)retry:(UIButton *)sender {
|
|
|
|
[self.player p2pStop];
|
|
[self.player.viewController.view removeFromSuperview];
|
|
self.player=nil;
|
|
[self connectDevice];
|
|
}
|
|
|
|
@end
|