Skip to content

Commit 9b183d9

Browse files
author
ccharlesren
committed
本都录像-首页回放添加本地录像入口;修改本地录像中信令参数live传错问题
Tapd: http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192865698219 Change-Id: I6b47fc3bbbfbe329e89769a9dc7df17597b01d4b
1 parent da29230 commit 9b183d9

File tree

6 files changed

+274
-73
lines changed

6 files changed

+274
-73
lines changed

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ PODS:
113113
- nanopb/decode (1.30906.0)
114114
- nanopb/encode (1.30906.0)
115115
- PromisesObjC (1.2.12)
116-
- Protobuf (3.19.0)
116+
- Protobuf (3.18.0)
117117
- QCloudCore (5.5.2)
118118
- QCloudCOSXML/Transfer (5.5.2):
119119
- QCloudCore (= 5.5.2)
@@ -251,7 +251,7 @@ SPEC CHECKSUMS:
251251
MJRefresh: ed450d6eb9d3346a2cb033ab7eb6de090aeef437
252252
nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc
253253
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
254-
Protobuf: e9b99dd5da72f665ec503b19191f245a22188b4d
254+
Protobuf: 1a37ebea1338949e9ac35a3f06e80b3f536eec8d
255255
QCloudCore: b91a762d280f0a80cc6f537fd186ac43a4a3025e
256256
QCloudCOSXML: a30ab17f45b0cbbcbb218a3677298498e8748a22
257257
SDWebImage: 624d6e296c69b244bcede364c72ae0430ac14681

Source/LinkSDKDemo/Video/DeviceHomeList/Controller/TIoTDemoHomeViewController.m

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#import "TIoTDemoPreviewDeviceVC.h"
2323
#import "TIoTDemoProductDetailModel.h"
2424
#import "TIoTDemoNVRSubDeviceVC.h"
25+
#import "TIoTDemoPlaybackVC.h"
2526

2627
static NSInteger const maxLimitDeviceNumber = 4;
2728
static NSString *const kVideoDeviceListCellID = @"kVideoDeviceListCellID";
@@ -219,10 +220,19 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
219220
ChooseFunctionBlock playbackVideoBlock = ^(TIoTDemoCustomSheetView *view){
220221
DDLogVerbose(@"回放");
221222
TIoTExploreOrVideoDeviceModel *model = self.dataArray[indexPath.row];
222-
TIoTCloudStorageVC *cloudStorageVC = [[TIoTCloudStorageVC alloc]init];
223-
cloudStorageVC.deviceModel = model;
224-
[self.navigationController pushViewController:cloudStorageVC animated:YES];
225-
[customActionSheet removeFromSuperview];
223+
// TIoTCloudStorageVC *cloudStorageVC = [[TIoTCloudStorageVC alloc]init];
224+
// cloudStorageVC.deviceModel = model;
225+
// [self.navigationController pushViewController:cloudStorageVC animated:YES];
226+
// [customActionSheet removeFromSuperview];
227+
228+
TIoTDemoPlaybackVC *playBackVC = [[TIoTDemoPlaybackVC alloc]init];
229+
playBackVC.deviceModel = model;
230+
playBackVC.isNVR = self.isNVR;
231+
playBackVC.deviceName = model.DeviceName;
232+
playBackVC.isFromHome = YES;
233+
234+
[self.navigationController pushViewController:playBackVC animated:YES];
235+
[customActionSheet removeFromSuperview];
226236
};
227237

228238
ChooseFunctionBlock cancelBlock = ^(TIoTDemoCustomSheetView *view) {

Source/LinkSDKDemo/Video/PlayBack/CloudStorage/Controller/TIoTCloudStorageVC.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ -(void)viewWillDisappear:(BOOL)animated{
141141
[self ratetePortrait];
142142

143143
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
144-
144+
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
145+
self.navigationController.navigationBar.translucent = NO;
145146
if (self.playerReloadBlock) {
146147
self.playerReloadBlock();
147148
}

Source/LinkSDKDemo/Video/PlayBack/LocalPlayBack/Controller/TIoTDemoLocalRecordVC.m

Lines changed: 78 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
static NSString *const kPlaybackCustomCellID = @"kPlaybackCustomCellID";
3636
static CGFloat const kScreenScale = 0.5625; //9/16 高宽比
3737

38-
static NSString *const kLive = @"ipc.flv?action=live";
38+
static NSString *const kPlayback = @"ipc.flv?action=playback";
3939

4040
@interface TIoTDemoLocalRecordVC ()<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
4141
@property (nonatomic, assign) CGRect screenRect;
@@ -98,6 +98,8 @@ - (void)viewDidLoad {
9898
[super viewDidLoad];
9999
// Do any additional setup after loading the view.
100100

101+
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
102+
101103
self.isHidePlayBtn = NO;
102104
self.isTimerSuspend = NO;
103105
self.screenRect = [UIApplication sharedApplication].delegate.window.frame;
@@ -317,7 +319,7 @@ - (void)setupUIViews {
317319
weakSelf.isHidePlayBtn = YES;
318320
weakSelf.isPause = NO;
319321
// [weakSelf playVideoWithStartTime:weakSelf.listModel.VideoURL withTime:previousModel isChangeModel:YES];
320-
[weakSelf seekDesignatedPointWithCurrentTime:previousModel.StartTime selectedTimeMoel:previousModel isChangeModel:YES];
322+
[weakSelf seekDesignatedPointWithCurrentTime:previousModel.StartTime selectedTimeMoel:previousModel isChangeModel:YES withProgress:NO];
321323
[weakSelf setScrollOffsetWith:previousModel];
322324
}
323325

@@ -342,7 +344,7 @@ - (void)setupUIViews {
342344
weakSelf.isHidePlayBtn = YES;
343345
weakSelf.isPause = NO;
344346
// [weakSelf playVideoWithStartTime:weakSelf.listModel.VideoURL withTime:nextModel isChangeModel:YES];
345-
[weakSelf seekDesignatedPointWithCurrentTime:nextModel.StartTime selectedTimeMoel:nextModel isChangeModel:YES];
347+
[weakSelf seekDesignatedPointWithCurrentTime:nextModel.StartTime selectedTimeMoel:nextModel isChangeModel:YES withProgress:NO];
346348
[weakSelf setScrollOffsetWith:nextModel];
347349
}
348350
};
@@ -385,7 +387,7 @@ - (void)setupUIViews {
385387
if (weakSelf.videoTimeModel.StartTime.integerValue <= startTimestamp && weakSelf.videoTimeModel.EndTime.integerValue >=startTimestamp ) {
386388

387389
if (weakSelf.player == nil) { //滑动到空数据,销毁player,重新请求
388-
[weakSelf seekDesignatedPointWithCurrentTime:videoPlayStart selectedTimeMoel:currentModel isChangeModel:YES];
390+
[weakSelf seekDesignatedPointWithCurrentTime:videoPlayStart selectedTimeMoel:currentModel isChangeModel:YES withProgress:NO];
389391
}else {
390392
if (weakSelf.isTimerSuspend == YES) {
391393
if (weakSelf.timer) {
@@ -405,11 +407,11 @@ - (void)setupUIViews {
405407
// [weakSelf tapVideoView:weakSelf.playPauseBtn];
406408
// }
407409
[weakSelf startPlayLocalVideoWithStartTime:currentModel.StartTime.integerValue endTime:currentModel.EndTime.integerValue sliderValue:videoPlayStart.integerValue];
408-
[weakSelf seekDesignatedPointWithCurrentTime:videoPlayStart selectedTimeMoel:currentModel isChangeModel:YES];
410+
[weakSelf seekDesignatedPointWithCurrentTime:videoPlayStart selectedTimeMoel:currentModel isChangeModel:YES withProgress:NO];
409411
}
410412

411413
}else {
412-
[weakSelf seekDesignatedPointWithCurrentTime:videoPlayStart selectedTimeMoel:currentModel isChangeModel:YES];
414+
[weakSelf seekDesignatedPointWithCurrentTime:videoPlayStart selectedTimeMoel:currentModel isChangeModel:YES withProgress:NO];
413415
}
414416

415417
TIoTDemoCloudEventModel *scorllCurrentModel = [[TIoTDemoCloudEventModel alloc]init];
@@ -550,7 +552,7 @@ - (void)getLocalDayTimeListDataWithCmd:(NSString *)actionString {
550552

551553
// 滚动到第一段视频起始位置开始播放
552554
self.choiceLocalDateView.nextDateBlcok(timeModel);
553-
// [self setVieoPlayerStartPlay];
555+
// [self setVieoPlayerStartPlayStartTime:<#(NSString *)#> endTime:<#(NSString *)#>];
554556
}
555557
}
556558

@@ -559,8 +561,9 @@ - (void)getLocalDayTimeListDataWithCmd:(NSString *)actionString {
559561
}];
560562
}
561563

562-
/// MARK: seek 进度条滚动
563-
- (void)seekDesignatedPointWithCurrentTime:(NSString *)currentTime selectedTimeMoel:(TIoTDemoCloudEventModel *)timeModel isChangeModel:(BOOL)isChange{
564+
/// MARK: seek 进度滚动控制
565+
//isControlProgress: 是否是播放器进度条
566+
- (void)seekDesignatedPointWithCurrentTime:(NSString *)currentTime selectedTimeMoel:(TIoTDemoCloudEventModel *)timeModel isChangeModel:(BOOL)isChange withProgress:(BOOL)isControlProgress{
564567

565568
if (isChange == YES) {
566569
self.videoTimeModel = [[TIoTDemoCloudEventModel alloc]init];
@@ -575,24 +578,29 @@ - (void)seekDesignatedPointWithCurrentTime:(NSString *)currentTime selectedTimeM
575578
channel = @"0";
576579
}
577580

578-
[self stopPlayMovie];
579-
580-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
581-
NSString *actionString = [NSString stringWithFormat:@"action=inner_define&channel=%@&cmd=playback_seek&time=%@",channel,currentTime];
582-
583-
[[TIoTCoreXP2PBridge sharedInstance] getCommandRequestWithAsync:self.deviceName?:@"" cmd:actionString timeout:2*1000*1000 completion:^(NSString * _Nonnull jsonList) {
581+
if (isControlProgress == NO) { //控制本地录像时间轴滚动
582+
[self stopPlayMovie];
583+
//seek 指定时间后,设备状态正常,可起播放器
584+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
585+
[self setVieoPlayerStartPlayStartTime:timeModel.StartTime endTime:timeModel.EndTime];
586+
});
587+
}else {
588+
//seek 播放器进度条后 不用重启播放器,播放流自动跟随时间播放
589+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
590+
NSString *actionString = [NSString stringWithFormat:@"action=inner_define&channel=%@&cmd=playback_seek&time=%@",channel,currentTime];
584591

585-
TIoTDemoDeviceStatusModel *responseModel = [TIoTDemoDeviceStatusModel yy_modelWithJSON:jsonList];
586-
if ([responseModel.status isEqualToString:@"0"]) {
587-
//seek 指定时间后,设备状态正常,可起播放器
588-
[self setVieoPlayerStartPlay];
592+
[[TIoTCoreXP2PBridge sharedInstance] getCommandRequestWithAsync:self.deviceName?:@"" cmd:actionString timeout:2*1000*1000 completion:^(NSString * _Nonnull jsonList) {
589593

590-
}else {
591-
//设备状态异常提示
592-
[TIoTCoreUtil showDeviceStatusError:responseModel commandInfo:[NSString stringWithFormat:@"发送信令: %@\n\n接收: %@",actionString,jsonList]];
593-
}
594-
}];
595-
});
594+
TIoTDemoDeviceStatusModel *responseModel = [TIoTDemoDeviceStatusModel yy_modelWithJSON:jsonList];
595+
if ([responseModel.status isEqualToString:@"0"]) {
596+
597+
}else {
598+
//设备状态异常提示
599+
[TIoTCoreUtil showDeviceStatusError:responseModel commandInfo:[NSString stringWithFormat:@"发送信令: %@\n\n接收: %@",actionString,jsonList]];
600+
}
601+
}];
602+
});
603+
}
596604
}
597605

598606
/// MARK: 发送暂停或继续播放信令
@@ -633,16 +641,16 @@ - (void)sendPauseOrResumeSignallingWithSwitch:(BOOL)isPause {
633641
}
634642

635643
/// MARK:开启设备
636-
- (void)setVieoPlayerStartPlay {
644+
- (void)setVieoPlayerStartPlayStartTime:(NSString *)startTime endTime:(NSString *)endTime {
637645

638646
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
639647

640648
NSString *channalID = @"";
641649

642650
if (self.isNVR == YES) {
643-
channalID = [NSString stringWithFormat:@"%@&channel=%@",kLive,self.deviceModel.Channel?:@""];
651+
channalID = [NSString stringWithFormat:@"%@&channel=%@&start_time=%@&end_time=%@",kPlayback,self.deviceModel.Channel?:@"",startTime,endTime];
644652
}else {
645-
channalID = [NSString stringWithFormat:@"%@&channel=0",kLive];
653+
channalID = [NSString stringWithFormat:@"%@&channel=0&start_time=%@&end_time=%@",kPlayback,startTime,endTime];
646654
}
647655

648656
NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:self.deviceName?:@""];
@@ -688,7 +696,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
688696
self.isPause = NO;
689697
TIoTDemoCloudEventModel *selectedModel = self.dataArray[indexPath.row];
690698
// [self playVideoWithStartTime:self.listModel.VideoURL withTime:selectedModel isChangeModel:YES];
691-
[self seekDesignatedPointWithCurrentTime:selectedModel.StartTime selectedTimeMoel:selectedModel isChangeModel:YES];
699+
[self seekDesignatedPointWithCurrentTime:selectedModel.StartTime selectedTimeMoel:selectedModel isChangeModel:YES withProgress:NO];
692700
[self setScrollOffsetWith:selectedModel];
693701
}
694702

@@ -811,23 +819,40 @@ - (void)initializedVideo {
811819
}
812820
}];
813821

814-
// self.playView = [[UIView alloc]init];
815-
// [self.imageView addSubview:self.playView];
816-
// [self.playView mas_makeConstraints:^(MASConstraintMaker *make) {
817-
// make.left.right.top.bottom.equalTo(self.imageView);
818-
// }];
819-
820-
// self.videoPlayBtn = [[UIButton alloc]init];
821-
// [self.videoPlayBtn setImage:[UIImage imageNamed:@"video_play"] forState:UIControlStateNormal];
822-
// [self.videoPlayBtn addTarget:self action:@selector(playVideo:) forControlEvents:UIControlEventTouchUpInside];
823-
// [self.playView addSubview:self.videoPlayBtn];
824-
// [self.videoPlayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
825-
// make.center.equalTo(self.playView);
826-
// make.width.height.mas_equalTo(60);
827-
// }];
822+
self.playView = [[UIView alloc]init];
823+
[self.imageView addSubview:self.playView];
824+
[self.playView mas_makeConstraints:^(MASConstraintMaker *make) {
825+
make.left.right.top.bottom.equalTo(self.imageView);
826+
}];
827+
828+
self.videoPlayBtn = [[UIButton alloc]init];
829+
[self.videoPlayBtn setImage:[UIImage imageNamed:@"video_play"] forState:UIControlStateNormal];
830+
[self.videoPlayBtn addTarget:self action:@selector(playVideo:) forControlEvents:UIControlEventTouchUpInside];
831+
[self.playView addSubview:self.videoPlayBtn];
832+
[self.videoPlayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
833+
make.center.equalTo(self.playView);
834+
make.width.height.mas_equalTo(60);
835+
}];
836+
837+
self.playView.hidden = YES;
828838

829839
}
830840

841+
///MARK:控制播放器进度条是否显示
842+
- (void)controlProgerssAppear:(UIButton *)button {
843+
if (self.customControlVidwoView.hidden == YES) {
844+
self.customControlVidwoView.hidden = NO;
845+
[self autoHideControlView];
846+
847+
}else {
848+
self.customControlVidwoView.hidden = YES;
849+
if (self.controlTimer != nil) {
850+
dispatch_source_cancel(self.controlTimer);
851+
self.controlTimer = nil;
852+
}
853+
}
854+
}
855+
831856
///MARK: 控制栏隐藏状态下tap Video时响应
832857
- (void)tapVideoView:(UIButton *)button {
833858

@@ -852,7 +877,7 @@ - (void)tapVideoView:(UIButton *)button {
852877

853878
if (self.isReAppearPause == YES) {
854879
//切换云存和本地tap时,player 进度条重新计算
855-
[self seekDesignatedPointWithCurrentTime:[NSString stringWithFormat:@"%ld",(long)self.currentTime] selectedTimeMoel:self.videoTimeModel isChangeModel:YES];
880+
[self seekDesignatedPointWithCurrentTime:[NSString stringWithFormat:@"%ld",(long)self.currentTime] selectedTimeMoel:self.videoTimeModel isChangeModel:YES withProgress:NO];
856881
}else {
857882
[self sendPauseOrResumeSignallingWithSwitch:NO];
858883
}
@@ -1005,7 +1030,7 @@ - (void)setupPlayerCustomControlView {
10051030
}else {
10061031
self.playPauseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
10071032
self.playPauseBtn.backgroundColor = [UIColor clearColor];
1008-
[self.playPauseBtn addTarget:self action:@selector(tapVideoView:) forControlEvents:UIControlEventTouchUpInside];
1033+
[self.playPauseBtn addTarget:self action:@selector(controlProgerssAppear:) forControlEvents:UIControlEventTouchUpInside];
10091034
[self.imageView addSubview:self.playPauseBtn];
10101035
[self.playPauseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
10111036
make.left.right.top.equalTo(self.imageView);
@@ -1078,11 +1103,11 @@ - (void)sliderValueChanged:(id)sender {
10781103
// [self tapVideoView:self.playPauseBtn];
10791104
}
10801105
self.isPause = NO;
1081-
self.player.currentPlaybackTime = self.currentTime;
1082-
[self startPlayLocalVideoWithStartTime:self.videoTimeModel.StartTime.integerValue endTime:self.videoTimeModel.EndTime.integerValue sliderValue:self.player.currentPlaybackTime];
1106+
// self.player.currentPlaybackTime = self.currentTime;
1107+
[self startPlayLocalVideoWithStartTime:self.videoTimeModel.StartTime.integerValue endTime:self.videoTimeModel.EndTime.integerValue sliderValue:self.currentTime];
10831108

10841109
// [self getFullVideoURLWithPartURL:self.listModel.VideoURL withTime:currentTimeModel isChangeModel:NO];
1085-
[self seekDesignatedPointWithCurrentTime:currentTimeModel.StartTime selectedTimeMoel:currentTimeModel isChangeModel:NO];
1110+
[self seekDesignatedPointWithCurrentTime:currentTimeModel.StartTime selectedTimeMoel:currentTimeModel isChangeModel:NO withProgress:YES];
10861111
[self setScrollOffsetWith:currentTimeModel];
10871112

10881113
}
@@ -1279,9 +1304,10 @@ - (void)localMoviePlayBackStateDidChange:(NSNotification*)notification
12791304
self.stopNumber += 1;
12801305
if (self.stopNumber == 2) {
12811306
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
1282-
[self configVideo];
1283-
[self.player prepareToPlay];
1284-
[self.player play];
1307+
// [self configVideo];
1308+
// [self.player prepareToPlay];
1309+
// [self.player play];
1310+
self.playView.hidden = NO;
12851311
});
12861312
}
12871313
break;
@@ -1451,7 +1477,7 @@ - (void)refushlocalVideo:(NSNotification *)notify {
14511477

14521478
[MBProgressHUD show:[NSString stringWithFormat:@"%@ 通道建立成功",selectedName] icon:@"" view:self.view];
14531479

1454-
[self seekDesignatedPointWithCurrentTime:[NSString stringWithFormat:@"%ld",self.currentTime] selectedTimeMoel:nil isChangeModel:NO];
1480+
[self seekDesignatedPointWithCurrentTime:[NSString stringWithFormat:@"%ld",self.currentTime] selectedTimeMoel:nil isChangeModel:NO withProgress:NO];
14551481
}
14561482

14571483
- (void)responseLocalP2PdisConnect:(NSNotification *)notify {

Source/LinkSDKDemo/Video/PlayBack/TIoTDemoPlaybackVC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef void(^TIoTDemoPlayerReloadBlock)(void);
2020

2121
@property (nonatomic, assign) BOOL isNVR;
2222
@property (nonatomic, copy) NSString *deviceName;
23-
23+
@property (nonatomic, assign) BOOL isFromHome;
2424
@end
2525

2626
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)