641 lines
23 KiB
Objective-C
641 lines
23 KiB
Objective-C
//
|
||
// IfishP2PPlayBackListViewController.m
|
||
// Ifish
|
||
//
|
||
// Created by imac on 16/12/6.
|
||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||
//
|
||
|
||
#import "IfishP2PPlayBackListViewController.h"
|
||
#import "CameraNoParyBackVideoView.h"
|
||
#import "P2PClient.h"
|
||
#import "IfishPlaybackViewCell.h"
|
||
#define BACKVIEW_ROWH 60
|
||
#define ANIM_VIEW_WIDTH_AND_HEIGHT 80
|
||
|
||
//新
|
||
#import "P2PPlayingbackVC.h"
|
||
@interface IfishP2PPlayBackListViewController ()<UITableViewDelegate,UITableViewDataSource,P2PPlaybackDelegate>
|
||
@property(nonatomic,strong)UITableView *tableView;
|
||
@property(retain, nonatomic) NSMutableArray *playbackFiles;
|
||
@property(retain, nonatomic) NSMutableArray *playbackSize;
|
||
@property(retain, nonatomic) NSMutableArray *timesData;
|
||
|
||
@property(retain, nonatomic) NSMutableArray *playbackFilesMore;
|
||
@property(retain, nonatomic) NSMutableArray *playbackSizeMore;
|
||
@property(retain, nonatomic) NSMutableArray *timesDataMore;
|
||
@property(nonatomic,strong) CameraNoParyBackVideoView *noDataView;
|
||
@property(strong, nonatomic) NSString *nextEndDate;
|
||
@property (nonatomic) BOOL isloadMore;//是否更多
|
||
@property(strong, nonatomic) UIView *movieView;
|
||
@property (nonatomic) BOOL isInItDevice; //是否连接设备
|
||
@end
|
||
|
||
@implementation IfishP2PPlayBackListViewController
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
[[P2PClient sharedClient] setIsClearPlaybackFilesLength:YES];//isClearPlaybackFilesLength
|
||
// Do any additional setup after loading the view.
|
||
_isloadMore = NO;
|
||
_isInItDevice = NO;
|
||
self.playbackFiles = [NSMutableArray arrayWithCapacity:0];
|
||
self.playbackSize = [NSMutableArray arrayWithCapacity:0];
|
||
self.playbackFilesMore = [NSMutableArray arrayWithCapacity:0];
|
||
self.playbackSizeMore = [NSMutableArray arrayWithCapacity:0];
|
||
[self addTitleViewWithTitle:@"回放"];
|
||
[self initUI];
|
||
|
||
//[[P2PClient sharedClient] setPlaybackDelegate:self];
|
||
}
|
||
|
||
#pragma mark - 初始化设备 p2pConnect
|
||
|
||
-(void)connectDevice{
|
||
|
||
//LoginResult *loginResult = [UDManager getLoginInfo];
|
||
//8225账号
|
||
// NSString * P2PVerifyCode1 = @"1528438234";
|
||
// NSString * P2PVerifyCode2 = @"992805759";
|
||
// NSString *UserID = @"-2144354932";
|
||
|
||
UserModel *model=[[DataCenter defaultDtacenter] valueForKey:@"UserLogIn"];
|
||
NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff];
|
||
|
||
|
||
//初始化设备
|
||
if (!_isInItDevice) {
|
||
NSLog(@"正在初始化设备");
|
||
_isInItDevice = [[P2PClient sharedClient] p2pConnectWithId:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2];
|
||
|
||
// _isInItDevice = [[P2PClient sharedClient] p2pConnectWithId:model.gwellUserID codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2];
|
||
|
||
}
|
||
|
||
|
||
if(_isInItDevice){
|
||
|
||
NSLog(@"p2pConnect success. 成功 可以操作设备了");
|
||
//成功 可以操作设备了
|
||
usleep(600000);
|
||
[self startMonitor];
|
||
|
||
}else{//new added
|
||
NSLog(@"p2pConnect failure.失败,不能操作设备");
|
||
//[self connectDevice];
|
||
return;
|
||
}
|
||
|
||
|
||
}
|
||
-(void)startMonitor{
|
||
|
||
if (_isInItDevice) {
|
||
NSLog(@"发送呼叫命令");
|
||
|
||
[[P2PClient sharedClient] setIsBCalled:NO];
|
||
[[P2PClient sharedClient] setP2pCallState:P2PCALL_STATUS_CALLING];
|
||
|
||
|
||
[[P2PClient sharedClient] p2pCallWithId:self.camera.cameraId password:self.camera.cameraPass callType:P2PCALL_TYPE_PLAYBACK];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
-(void)viewWillAppear:(BOOL)animated{
|
||
[super viewWillAppear:animated];
|
||
[AppDelegate sharedDefault].canFullScreen = YES;
|
||
// [self connectDevice];
|
||
}
|
||
|
||
|
||
-(void)viewWillDisappear:(BOOL)animated{
|
||
[super viewWillDisappear:animated];
|
||
//[AppDelegate sharedDefault].canFullScreen = YES;
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"read_play_false" object:nil];
|
||
}
|
||
|
||
-(void)viewDidAppear:(BOOL)animated{
|
||
[super viewDidAppear:animated];
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil];
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readPlayFalse:) name:@"read_play_false" object:nil];
|
||
|
||
[[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass];
|
||
|
||
|
||
}
|
||
|
||
-(void)readPlayFalse:(NSNotification*)noti{
|
||
///
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 0.3;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
[self.movieView setHidden:YES];
|
||
[self.view makeToast:NSLocalizedString(@"connection_failed_please_reconnect", nil)];
|
||
}
|
||
];
|
||
});
|
||
}
|
||
|
||
|
||
-(void)goBackAction{
|
||
|
||
// [[P2PClient sharedClient] p2pHungUp];
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
}
|
||
|
||
|
||
- (void)receiveRemoteMessage:(NSNotification *)notification{
|
||
|
||
NSDictionary *parameter = [notification userInfo];
|
||
int key = [[parameter valueForKey:@"key"] intValue];
|
||
|
||
switch (key) {
|
||
case RET_GET_PLAYBACK_FILES:
|
||
{
|
||
//回放文件名称
|
||
NSArray *array = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"files"]];
|
||
//回放文件的时间记录
|
||
NSArray *times = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"times"]];
|
||
//回放文件的播放时长
|
||
NSArray *sizes = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"sizes"]];
|
||
|
||
|
||
//若不是加载更多时,则往已playbackFiles数组存放回放文件
|
||
//若是加载更多,则往playbackFilesMore的数组添加回放文件
|
||
//若不是加载更多时,则往playbackSize数组存放回放文件的播放时长
|
||
//若是上拉加载更多,则往playbackSizeMore数组末尾添加回放文件的播放时长
|
||
if (_isloadMore) {
|
||
|
||
for (NSString *file in array){
|
||
[self.playbackFilesMore addObject:file];
|
||
}
|
||
for (NSString *size in sizes){
|
||
[self.playbackSizeMore addObject:size];
|
||
}
|
||
//刷新表格
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[self.tableView reloadData];
|
||
if (self.playbackFilesMore.count < 1) {
|
||
//[self.view makeToast:NSLocalizedString(@"no_playback_file", nil)];
|
||
[self.view makeToast:@"没有更多视频"];
|
||
}
|
||
});
|
||
self.timesDataMore = [NSMutableArray arrayWithArray:times];
|
||
if (self.timesDataMore.count==0) {
|
||
return;
|
||
}
|
||
|
||
//记录最近1天、3天...已显示文件里最后一个文件的时间(最早文件的时间)
|
||
//用于上拉加载时传入的结束时间
|
||
self.nextEndDate = [self.timesDataMore lastObject];
|
||
|
||
}else{
|
||
|
||
for (NSString *file in array){
|
||
[self.playbackFiles addObject:file];
|
||
}
|
||
for (NSString *size in sizes){
|
||
[self.playbackSize addObject:size];
|
||
}
|
||
//刷新表格
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[self.tableView reloadData];
|
||
if (self.playbackFiles.count < 1) {
|
||
//[self.view makeToast:NSLocalizedString(@"no_playback_file", nil)];
|
||
[self initNoVideoDataViewHidden:NO];
|
||
|
||
}
|
||
});
|
||
|
||
self.timesData = [NSMutableArray arrayWithArray:times];
|
||
if (self.timesData.count==0) {
|
||
return;
|
||
}
|
||
|
||
//记录最近1天、3天...已显示文件里最后一个文件的时间(最早文件的时间)
|
||
//用于上拉加载时传入的结束时间
|
||
self.nextEndDate = [self.timesData lastObject];
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
case RET_GET_SDCARD_INFO:
|
||
|
||
{
|
||
NSInteger result = [[parameter valueForKey:@"result"] intValue];
|
||
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
if (result == 1) {
|
||
|
||
//[self.view makeToast:@"sdk卡可使用"];
|
||
[[P2PClient sharedClient] setCurrentLabel:1];
|
||
[[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:1];
|
||
[[P2PClient sharedClient] setPlaybackDelegate:self];
|
||
|
||
}else{
|
||
//sd卡不存在,
|
||
//[self.view makeToast:NSLocalizedString(@"no_storage", nil)];
|
||
[self initNoSDDataViewHidden:NO];
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
-(void)initNoSDDataViewHidden:(BOOL)hidden
|
||
|
||
{
|
||
if (hidden) {
|
||
|
||
[self.noDataView removeFromSuperview];
|
||
|
||
return;
|
||
}
|
||
|
||
if (!self.noDataView) {
|
||
|
||
self.noDataView = [[CameraNoParyBackVideoView alloc] initWithFrame:self.view.bounds];
|
||
|
||
[self.view addSubview:self.noDataView];
|
||
}
|
||
|
||
UIImage *img=LXImageWithImageName(@"playback_iocn_sdk");
|
||
self.noDataView.dataType = noDataViewTypeNOSDCard;
|
||
[self.noDataView setViewData:img title:@"未检测到SD卡" subTitle:@"请将SD卡插入摄像头对应的卡槽中"];
|
||
|
||
}
|
||
|
||
-(void)initNoVideoDataViewHidden:(BOOL)hidden
|
||
{
|
||
if (!self.noDataView) {
|
||
//CGFloat viewH =200;
|
||
self.noDataView = [[CameraNoParyBackVideoView alloc] initWithFrame:self.view.bounds];
|
||
[self.view addSubview:self.noDataView];
|
||
}
|
||
|
||
self.noDataView.dataType = noDataViewTypeNOVideo;
|
||
UIImage *img=LXImageWithImageName(@"playback_iocn_sp");
|
||
[self.noDataView setViewData:img title:@"还没有视频哦~" subTitle:@""];
|
||
self.noDataView.hidden = hidden;
|
||
|
||
|
||
}
|
||
-(void)initUI
|
||
{
|
||
|
||
|
||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
|
||
self.tableView.delegate = self;
|
||
self.tableView.dataSource = self;
|
||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
self.tableView.showsVerticalScrollIndicator = NO;
|
||
self.tableView.backgroundColor = RGB(241, 241, 241);
|
||
[self.view addSubview:self.tableView];
|
||
|
||
UIView *movieView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, self.view.frame.size.width, self.view.frame.size.height-NAVIGATION_BAR_HEIGHT)];
|
||
[movieView setBackgroundColor:XBlack_128];
|
||
|
||
UIImageView *animView = [[UIImageView alloc] initWithFrame:CGRectMake((movieView.frame.size.width-ANIM_VIEW_WIDTH_AND_HEIGHT)/2, (movieView.frame.size.height-ANIM_VIEW_WIDTH_AND_HEIGHT)/2, ANIM_VIEW_WIDTH_AND_HEIGHT, ANIM_VIEW_WIDTH_AND_HEIGHT)];
|
||
|
||
NSArray *imagesArray = [NSArray arrayWithObjects:LXImageWithImageName(@"movie1.png"),LXImageWithImageName(@"movie2.png"),LXImageWithImageName(@"movie3.png"),nil];
|
||
|
||
animView.animationImages = imagesArray;
|
||
animView.animationDuration = ((CGFloat)[imagesArray count])*100.0f/1000.0f;
|
||
animView.animationRepeatCount = 0;
|
||
[animView startAnimating];
|
||
[movieView addSubview:animView];
|
||
[movieView setHidden:YES];
|
||
[self.view addSubview:movieView];
|
||
self.movieView = movieView;
|
||
|
||
|
||
}
|
||
- (void)didReceiveMemoryWarning {
|
||
[super didReceiveMemoryWarning];
|
||
// Dispose of any resources that can be recreated.
|
||
}
|
||
|
||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||
|
||
return 2;
|
||
|
||
}
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||
if (section ==0) {
|
||
|
||
return [self.playbackFiles count];
|
||
}
|
||
return [self.playbackFilesMore count];
|
||
|
||
}
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
return BACKVIEW_ROWH;
|
||
|
||
}
|
||
|
||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
|
||
IfishPlaybackViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishPlaybackViewCell"];
|
||
if (!cell) {
|
||
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishPlaybackViewCell" owner:self options:nil]lastObject];
|
||
|
||
}
|
||
|
||
//每一分区这里加载不同数据源
|
||
if (indexPath.section ==0) {
|
||
if (self.playbackFiles.count!=0) {
|
||
|
||
NSString* name = [self.playbackFiles objectAtIndex:indexPath.row];
|
||
|
||
int iSize = 0;
|
||
if ([self.playbackFiles count] == [self.playbackSize count]) //查询到了文件长度
|
||
{
|
||
NSNumber* number = [self.playbackSize objectAtIndex:indexPath.row];
|
||
iSize = [number intValue];
|
||
}
|
||
if (iSize != 0) {//支持返回播放时长
|
||
//cell.videoTime.text = [NSString stringWithFormat:@"%@ (%02d:%02d)", name, iSize/60, iSize%60];
|
||
cell.videoTime.text = [NSString stringWithFormat:@"%@", name];
|
||
cell.videoLongth.text = [NSString stringWithFormat:@"%02d分钟",iSize/60];
|
||
if (iSize<60) {
|
||
|
||
cell.videoLongth.text = [NSString stringWithFormat:@"%02d秒钟",iSize%60];
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
cell.videoTime.text = [NSString stringWithFormat:@"%@", name];
|
||
cell.videoLongth.text = @"未知";
|
||
}
|
||
|
||
}
|
||
|
||
}else{
|
||
//更多
|
||
if (self.playbackFilesMore.count !=0) {
|
||
|
||
NSString* name = [self.playbackFilesMore objectAtIndex:indexPath.row];
|
||
|
||
int iSize = 0;
|
||
if ([self.playbackFilesMore count] == [self.playbackSizeMore count]) //查询到了文件长度
|
||
{
|
||
NSNumber* number = [self.playbackSizeMore objectAtIndex:indexPath.row];
|
||
iSize = [number intValue];
|
||
}
|
||
if (iSize != 0) {//支持返回播放时长
|
||
//cell.videoTime.text = [NSString stringWithFormat:@"%@ (%02d:%02d)", name, iSize/60, iSize%60];
|
||
cell.videoTime.text = [NSString stringWithFormat:@"%@", name];
|
||
cell.videoLongth.text = [NSString stringWithFormat:@"%02d分钟",iSize/60];
|
||
|
||
}
|
||
else
|
||
{
|
||
cell.videoTime.text = [NSString stringWithFormat:@"%@", name];
|
||
cell.videoLongth.text = @"未知";
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
return cell;
|
||
|
||
}
|
||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
[self.movieView setHidden:NO];
|
||
self.movieView.alpha = 0.3;
|
||
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 1.0;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
|
||
}
|
||
];
|
||
if (indexPath.section ==0) {
|
||
|
||
[[P2PClient sharedClient] p2pPlaybackCallWithId:self.camera.cameraId password:self.camera.cameraPass index:indexPath.row];
|
||
|
||
}else{
|
||
[[P2PClient sharedClient] p2pPlaybackCallWithId:self.camera.cameraId password:self.camera.cameraPass index:indexPath.row + self.playbackFiles.count];
|
||
}
|
||
|
||
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
|
||
if (section==0) {
|
||
//描述 + 回放列表 + 今天 + 1 像素线
|
||
return 50 +BACKVIEW_ROWH +BACKVIEW_ROWH + 1;
|
||
}
|
||
return 0.1;
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||
|
||
if (section ==1) {
|
||
|
||
return BACKVIEW_ROWH;
|
||
}
|
||
return 0.1;
|
||
}
|
||
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||
|
||
CGFloat space = 10;
|
||
|
||
if (section ==0) {
|
||
|
||
UIView *section0Header =[[UIView alloc] init];
|
||
section0Header.frame = CGRectMake(0, 0, self.view.frame.size.width, 191);
|
||
|
||
UILabel *describleLabe=[[UILabel alloc] init];
|
||
describleLabe.frame = CGRectMake(0, 0,self.view.frame.size.width, 50);
|
||
describleLabe.textColor =RGB(102, 102, 102);
|
||
describleLabe.textAlignment = NSTextAlignmentCenter;
|
||
describleLabe.text = @"30分钟录制一次,录像最多存储7日";
|
||
describleLabe.font = [UIFont systemFontOfSize:12];
|
||
describleLabe.backgroundColor = RGB(241, 245, 246);
|
||
|
||
[section0Header addSubview:describleLabe];
|
||
|
||
UIView *listLabeBack =[[UIView alloc] init];
|
||
listLabeBack.frame = CGRectMake(0,CGRectGetMaxY(describleLabe.frame), self.view.frame.size.width,BACKVIEW_ROWH);
|
||
listLabeBack.backgroundColor = [UIColor whiteColor];
|
||
|
||
[section0Header addSubview:listLabeBack];
|
||
|
||
UILabel *listLabe=[[UILabel alloc] init];
|
||
listLabe.frame = CGRectMake(space,CGRectGetHeight(listLabeBack.frame)/2,200, 20);
|
||
listLabe.textColor =RGB(102, 102, 102);
|
||
listLabe.font = [UIFont systemFontOfSize:15];
|
||
listLabe.text = @"回放列表";
|
||
[listLabeBack addSubview:listLabe];
|
||
CGFloat listlW = 50;
|
||
UILabel *listl=[[UILabel alloc] init];
|
||
listl.frame = CGRectMake(self.view.frame.size.width - space -listlW -4,CGRectGetHeight(listLabeBack.frame)/2,listlW, 20);
|
||
listl.textColor =RGB(102, 102, 102);
|
||
listl.font = [UIFont systemFontOfSize:14];
|
||
listl.text = @"时长";
|
||
listl.textAlignment = NSTextAlignmentRight;
|
||
[listLabeBack addSubview:listl];
|
||
|
||
|
||
//一像素分割线
|
||
UIView *lineView =[[UIView alloc] init];
|
||
lineView.frame = CGRectMake(0, CGRectGetMaxY(listLabeBack.frame), self.view.frame.size.width,1);
|
||
lineView.backgroundColor = RGB(241, 241, 241);
|
||
[section0Header addSubview:lineView];
|
||
//今天
|
||
UIView *todayLabeBack =[[UIView alloc] init];
|
||
todayLabeBack.frame = CGRectMake(0,CGRectGetMaxY(lineView.frame),self.view.frame.size.width, BACKVIEW_ROWH);
|
||
todayLabeBack.backgroundColor = [UIColor whiteColor];
|
||
|
||
[section0Header addSubview:todayLabeBack];
|
||
UILabel *todayLabe=[[UILabel alloc] init];
|
||
todayLabe.frame = CGRectMake(space,0,self.view.frame.size.width, BACKVIEW_ROWH);
|
||
todayLabe.textColor =RGB(153, 153, 153);
|
||
todayLabe.font = [UIFont systemFontOfSize:14];
|
||
todayLabe.text = @"最近24小时";
|
||
todayLabe.backgroundColor = [UIColor whiteColor];
|
||
//todayLabe.text.
|
||
[todayLabeBack addSubview:todayLabe];
|
||
|
||
|
||
|
||
return section0Header;
|
||
}
|
||
|
||
return nil;
|
||
|
||
}
|
||
|
||
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
||
CGFloat space = 10;
|
||
|
||
if (section ==1) {
|
||
//更多
|
||
UIView *moreLabeBack =[[UIView alloc] init];
|
||
moreLabeBack.frame = CGRectMake(0,0,self.view.frame.size.width, BACKVIEW_ROWH);
|
||
moreLabeBack.backgroundColor = [UIColor whiteColor];
|
||
UILabel *moreLabe=[[UILabel alloc] init];
|
||
moreLabe.frame = CGRectMake(space,0,self.view.frame.size.width, BACKVIEW_ROWH);
|
||
moreLabe.textColor =RGB(153, 153, 153);
|
||
moreLabe.font = [UIFont systemFontOfSize:14];
|
||
moreLabe.text = @"查看更多";
|
||
moreLabe.backgroundColor = [UIColor whiteColor];
|
||
[moreLabeBack addSubview:moreLabe];
|
||
moreLabe.userInteractionEnabled = YES;
|
||
UITapGestureRecognizer *moreGesture =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreDataRequset)];
|
||
[moreLabe addGestureRecognizer:moreGesture];
|
||
|
||
return moreLabeBack;
|
||
|
||
}
|
||
return nil;
|
||
}
|
||
#pragma mark - moreDataRequset
|
||
|
||
-(void)moreDataRequset{
|
||
_isloadMore =YES;
|
||
// //today
|
||
NSDate *nowDate = [NSDate date];
|
||
NSInteger interval =31;
|
||
// //interval(1或3...)天前
|
||
NSDate *startDate = [nowDate dateByAddingTimeInterval: -(interval*24*60*60)];
|
||
//加载更多时 设置 startDate 为31 天前 可获取所有 endDate 为 今天最后一个的时间 即self.nextEndDate
|
||
if (!self.nextEndDate) {
|
||
[self.view makeToast:@"无更多数据"];
|
||
return;
|
||
}
|
||
|
||
NSDate *endDate = [Utils dateFromString:self.nextEndDate];
|
||
[[P2PClient sharedClient] getPlaybackFilesWithIdByDate:self.camera.cameraId password:self.camera.cameraPass startDate:startDate endDate:endDate];
|
||
|
||
}
|
||
|
||
#pragma mark - 视频回放准备播放的回调
|
||
-(void)P2PPlaybackReady:(NSDictionary *)info{
|
||
NSLog(@"P2PPlaybackReady");
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 0.3;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
[self.movieView setHidden:YES];
|
||
//P2PPlayingbackController *playingbackController = [[P2PPlayingbackController alloc] init];
|
||
|
||
P2PPlayingbackVC *playingbackController = [[P2PPlayingbackVC alloc] init];
|
||
[self presentViewController:playingbackController animated:YES completion:nil];
|
||
|
||
}
|
||
];
|
||
});
|
||
}
|
||
|
||
#pragma mark - 视频回放挂断的回调
|
||
-(void)P2PPlaybackReject:(NSDictionary *)info{
|
||
|
||
NSLog(@"P2PPlaybackReject");
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
[UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut
|
||
animations:^{
|
||
self.movieView.alpha = 0.3;
|
||
}
|
||
|
||
completion:^(BOOL finished){
|
||
[self.movieView setHidden:YES];
|
||
[self.view makeToast:[info objectForKey:@"rejectMsg"]];
|
||
}
|
||
];
|
||
});
|
||
}
|
||
|
||
#pragma mark -
|
||
-(BOOL)shouldAutorotate{
|
||
return YES;
|
||
}
|
||
|
||
#pragma mark 支持哪些方向
|
||
|
||
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
|
||
return UIInterfaceOrientationMaskAll;
|
||
}
|
||
|
||
#pragma mark 一开始希望的屏幕方向
|
||
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
|
||
return UIInterfaceOrientationPortrait;
|
||
}
|
||
|
||
@end
|