Skip to content

Commit d8bda52

Browse files
author
ccharlesren
committed
滚动时间抽进度条对应seek到对应时刻继续播放
Tapd: http://tapd.oa.com/NEW_IOT/prong/stories/view/1020393192865698219 Change-Id: Iec10893dce63e891af9b110ded0b6cfb528ae6c6
1 parent 95f2510 commit d8bda52

File tree

1 file changed

+26
-166
lines changed

1 file changed

+26
-166
lines changed

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

Lines changed: 26 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -548,55 +548,6 @@ - (void)setVieoPlayerStartPlay {
548548
});
549549
}
550550

551-
//MARK:获取某一天云存时间轴
552-
//- (void)requestCloudStorageDayDate {
553-
//
554-
// NSMutableDictionary *paramDic = [[NSMutableDictionary alloc]init];
555-
// paramDic[@"ProductId"] = [TIoTCoreAppEnvironment shareEnvironment].cloudProductId?:@"";
556-
// paramDic[@"DeviceName"] = self.deviceModel.DeviceName?:@"";
557-
// paramDic[@"Date"] = self.currentDayTime?:@"";
558-
// paramDic[@"Version"] = @"2020-12-15";
559-
// [[TIoTCoreDeviceSet shared] requestVideoOrExploreDataWithParam:paramDic action:DescribeCloudStorageTime vidowOrExploreHost:TIotApiHostVideo success:^(id _Nonnull responseObject) {
560-
// TIoTCloudStorageDayTimeListModel *data = [TIoTCloudStorageDayTimeListModel yy_modelWithJSON:responseObject[@"Data"]];
561-
//
562-
// //data.VideoURL 需要拼接
563-
// self.timeList = [NSArray arrayWithArray:data.TimeList?:@[]];
564-
//
565-
// [self recombineTimeSegmentWithTimeArray:self.timeList];
566-
//
567-
// self.choiceDateView.videoTimeSegmentArray = self.modelArray;
568-
//
569-
// if (self.eventItemModel != nil) {
570-
// self.currentTime = 0;
571-
// self.scrollDuraionTime = self.currentTime;
572-
// self.isInnerScroll = NO;
573-
// self.isPause = NO;
574-
// [self getFullVideoURLWithPartURL:data.VideoURL?:@"" withTime:self.eventItemModel isChangeModel:YES];
575-
// }else {
576-
// if (self.modelArray.count != 0) {
577-
// TIoTTimeModel *timeModel = self.modelArray[0]?:[[TIoTTimeModel alloc]init];
578-
// TIoTDemoCloudEventModel *model = [[TIoTDemoCloudEventModel alloc]init];
579-
//
580-
// NSString *startString = [self getDeytimeFormat:round(timeModel.startTime?:0)];
581-
// NSString *endString = [self getDeytimeFormat:round(timeModel.endTime?:0)];
582-
// model.StartTime = [NSString getTimeStampWithString:startString?:@"" withFormatter:@"YYYY-MM-dd HH:mm:ss" withTimezone:@""];
583-
// model.EndTime = [NSString getTimeStampWithString:endString?:@"" withFormatter:@"YYYY-MM-dd HH:mm:ss" withTimezone:@""];
584-
//
585-
// self.currentTime = 0;
586-
// self.scrollDuraionTime = self.currentTime;
587-
// self.isInnerScroll = NO;
588-
// self.isPause = NO;
589-
// [self getFullVideoURLWithPartURL:data.VideoURL?:@"" withTime:model isChangeModel:YES];
590-
// // [self setScrollOffsetWith:timeModel];
591-
// }
592-
// }
593-
//
594-
//
595-
// } failure:^(NSString * _Nullable reason, NSError * _Nullable error, NSDictionary * _Nullable dic) {
596-
//
597-
// }];
598-
//}
599-
600551
- (NSString *)getDeytimeFormat:(NSInteger)timestamp {
601552
NSInteger hour = timestamp / (60*60);
602553
NSInteger mintue = timestamp % (60*60) / 60;
@@ -607,109 +558,6 @@ - (NSString *)getDeytimeFormat:(NSInteger)timestamp {
607558
return dateString;
608559
}
609560

610-
///MARK: 获取视频防盗链播放URL
611-
//- (void)getFullVideoURLWithPartURL:(NSString *)videoPartURL withTime:(TIoTDemoCloudEventModel *)timeModel isChangeModel:(BOOL)isChange
612-
//{
613-
// NSString *currentStamp = [NSString getNowTimeString];
614-
//
615-
// NSMutableDictionary *paramDic = [[NSMutableDictionary alloc]init];
616-
// paramDic[@"Version"] = @"2020-12-15";
617-
// paramDic[@"VideoURL"] = [NSString stringWithFormat:@"%@?starttime_epoch=%ld&endtime_epoch=%ld",videoPartURL,(long)timeModel.StartTime.integerValue,(long)timeModel.EndTime.integerValue]?:@"";
618-
// paramDic[@"ExpireTime"] = [NSNumber numberWithInteger:currentStamp.integerValue + 3600];
619-
// [[TIoTCoreDeviceSet shared] requestVideoOrExploreDataWithParam:paramDic action:GenerateSignedVideoURL vidowOrExploreHost:TIotApiHostVideo success:^(id _Nonnull responseObject) {
620-
// TIoTDemoCloudStoreFullVideoUrl *fullVideoURl = [TIoTDemoCloudStoreFullVideoUrl yy_modelWithJSON:responseObject];
621-
// DDLogDebug(@"--fullVideoURL--%@",fullVideoURl.SignedVideoURL);
622-
//
623-
// if (timeModel.EndTime.integerValue == 0 || [NSString isNullOrNilWithObject:timeModel.EndTime]) {
624-
// [MBProgressHUD showError:@"视频连接有误"];
625-
// }
626-
//
627-
// if (isChange == YES) {
628-
// self.videoTimeModel = [[TIoTDemoCloudEventModel alloc]init];
629-
// self.videoTimeModel.StartTime = timeModel.StartTime;
630-
// self.videoTimeModel.EndTime = timeModel.EndTime;
631-
// }
632-
//
633-
// //视频播放
634-
// self.videoUrl = fullVideoURl.SignedVideoURL?:@"";
635-
// if (self.isHidePlayBtn == YES) {
636-
// [self stopPlayMovie];
637-
// [self configVideo];
638-
// [self.player prepareToPlay];
639-
// [self.player play];
640-
// [self autoHideControlView];
641-
// }
642-
// [MBProgressHUD dismissInView:self.view];
643-
// } failure:^(NSString * _Nullable reason, NSError * _Nullable error, NSDictionary * _Nullable dic) {
644-
// [MBProgressHUD dismissInView:self.view];
645-
// }];
646-
//}
647-
648-
///MARK: 云存事件列表
649-
//- (void)requestCloudStoreVideoList {
650-
//
651-
// [MBProgressHUD showLodingNoneEnabledInView:self.view withMessage:@""];
652-
//
653-
// NSString *startString = [NSString stringWithFormat:@"%@ 00:00:00",self.currentDayTime?:@""];
654-
// NSString *endString = [NSString stringWithFormat:@"%@ 23:59:59",self.currentDayTime?:@""];
655-
// NSString *startTimestampString = [NSString getTimeStampWithString:startString withFormatter:@"YYYY-MM-dd HH:mm:ss" withTimezone:@""];
656-
// NSString *endTimesstampString = [NSString getTimeStampWithString:endString withFormatter:@"YYYY-MM-dd HH:mm:ss" withTimezone:@""];
657-
//
658-
// NSMutableDictionary *paramDic = [[NSMutableDictionary alloc]init];
659-
// paramDic[@"ProductId"] = [TIoTCoreAppEnvironment shareEnvironment].cloudProductId?:@"";
660-
// paramDic[@"Version"] = @"2020-12-15";
661-
// paramDic[@"Size"] = [NSNumber numberWithInteger:kLimit];
662-
// paramDic[@"DeviceName"] = self.deviceModel.DeviceName?:@"";
663-
// paramDic[@"StartTime"] = [NSNumber numberWithInteger:startTimestampString.integerValue];
664-
// paramDic[@"EndTime"] = [NSNumber numberWithInteger:endTimesstampString.integerValue];
665-
// [[TIoTCoreDeviceSet shared] requestVideoOrExploreDataWithParam:paramDic action:DescribeCloudStorageEvents vidowOrExploreHost:TIotApiHostVideo success:^(id _Nonnull responseObject) {
666-
//
667-
// self.listModel = [TIoTDemoCloudEventListModel yy_modelWithJSON:responseObject];
668-
//
669-
// if (self.listModel.Events.count != 0) {
670-
// NSMutableArray *temp = (NSMutableArray *)[[self.listModel.Events?:@[] reverseObjectEnumerator] allObjects];
671-
// self.dataArray = [NSMutableArray arrayWithArray:temp?:@[]];
672-
// self.dataArray = (NSMutableArray *)[[self.dataArray reverseObjectEnumerator] allObjects];
673-
// self.currentTime = 0;
674-
// self.scrollDuraionTime = self.currentTime;
675-
// self.isInnerScroll = NO;
676-
// self.isPause = NO;
677-
//// [self getFullVideoURLWithPartURL:self.listModel.VideoURL?:@"" withTime:self.dataArray[0] isChangeModel:YES];
678-
// [self setScrollOffsetWith:self.dataArray.lastObject];
679-
//
680-
// [self.tableView reloadData];
681-
//
682-
// [self.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
683-
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
684-
// TIoTDemoCloudEventModel *model = obj;
685-
// [self requestCloudStoreUrlWithThumbnail:model index:idx];
686-
// });
687-
//
688-
// }];
689-
// }
690-
// [MBProgressHUD dismissInView:self.view];
691-
// } failure:^(NSString * _Nullable reason, NSError * _Nullable error, NSDictionary * _Nullable dic) {
692-
// [MBProgressHUD dismissInView:self.view];
693-
// }];
694-
//}
695-
696-
///MARK: 云存事件缩略图
697-
//- (void)requestCloudStoreUrlWithThumbnail:(TIoTDemoCloudEventModel *)eventModel index:(NSInteger)index {
698-
// NSMutableDictionary *paramDic = [[NSMutableDictionary alloc]init];
699-
// paramDic[@"ProductId"] = [TIoTCoreAppEnvironment shareEnvironment].cloudProductId?:@"";
700-
// paramDic[@"Version"] = @"2020-12-15";
701-
// paramDic[@"DeviceName"] = self.deviceModel.DeviceName?:@"";
702-
// paramDic[@"Thumbnail"] = eventModel.Thumbnail?:@"";
703-
// [[TIoTCoreDeviceSet shared] requestVideoOrExploreDataWithParam:paramDic action:DescribeCloudStorageThumbnail vidowOrExploreHost:TIotApiHostVideo success:^(id _Nonnull responseObject) {
704-
// TIoTDemoCloudEventModel *tuumbnailModel = [TIoTDemoCloudEventModel yy_modelWithJSON:responseObject];
705-
// eventModel.ThumbnailURL = tuumbnailModel.ThumbnailURL;
706-
// [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
707-
// } failure:^(NSString * _Nullable reason, NSError * _Nullable error, NSDictionary * _Nullable dic) {
708-
//
709-
// }];
710-
//
711-
//}
712-
713561
#pragma mark - UITableViewDelegate UITableViewDataSource
714562
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
715563
return self.dataArray.count;
@@ -952,16 +800,11 @@ - (void)playVideo:(UIButton *)button {
952800
///MARK: 设置播放器样式
953801
- (void)setupPlayerCustomControlView {
954802

955-
if (self.customControlVidwoView != nil) {
956-
[self.customControlVidwoView removeFromSuperview];
957-
}
958-
if (self.playPauseBtn != nil) {
959-
[self.playPauseBtn removeFromSuperview];
960-
}
803+
[self clearPlayerControlView];
961804

962805
//播放时长 时间戳差值
963806
// NSInteger durationValue = self.videoTimeModel.EndTime.integerValue - self.videoTimeModel.StartTime.integerValue;
964-
NSInteger durationValue = self.player.duration; //+ self.scrollDuraionTime;
807+
NSInteger durationValue = self.videoTimeModel.EndTime.integerValue - self.videoTimeModel.StartTime.integerValue; //+ self.scrollDuraionTime;
965808
NSInteger minuteValue = durationValue / 60;
966809
NSInteger secondValue = durationValue % 60;
967810

@@ -1077,7 +920,7 @@ - (void)sliderValueChanged:(id)sender {
1077920

1078921
UISlider *slider = (UISlider *)sender;
1079922
self.currentTime = round(slider.value);
1080-
DDLogVerbose(@"currentPlaybackTime %f \n---start:%f----\n ent:%f\n",round(self.player.currentPlaybackTime),round(self.player.playableDuration) ,round(self.player.duration));
923+
// DDLogVerbose(@"currentPlaybackTime %f \n---start:%f----\n ent:%f\n",round(self.player.currentPlaybackTime),round(self.player.playableDuration) ,round(self.videoTimeModel.EndTime.integerValue - self.videoTimeModel.StartTime.integerValue));
1081924

1082925
TIoTDemoCloudEventModel *currentTimeModel = [[TIoTDemoCloudEventModel alloc]init];
1083926
if (self.isInnerScroll == YES) {
@@ -1325,6 +1168,10 @@ - (void)moviePlayBackStateDidChange:(NSNotification*)notification
13251168
// self.player.currentPlaybackTime = self.currentTime;
13261169
// }
13271170
// [self startPlayVideoWithStartTime:self.videoTimeModel.StartTime.integerValue endTime:self.videoTimeModel.EndTime.integerValue sliderValue:self.currentTime];
1171+
1172+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
1173+
[self startPlayVideoWithStartTime:self.videoTimeModel.StartTime.integerValue endTime:self.videoTimeModel.EndTime.integerValue sliderValue:self.currentTime];
1174+
});
13281175
[MBProgressHUD dismissInView:self.view];
13291176
break;
13301177
}
@@ -1369,14 +1216,15 @@ - (void)startPlayVideoWithStartTime:(NSInteger )startTime endTime:(NSInteger )en
13691216

13701217
__block NSInteger time = sliderValue; //计时开始
13711218

1372-
NSInteger durationValue = self.player.duration;
1219+
// NSInteger durationValue = self.player.duration;
1220+
NSInteger durationValue = self.videoTimeModel.EndTime.integerValue - self.videoTimeModel.StartTime.integerValue;
13731221
NSInteger minuteValue = durationValue / 60;
13741222
NSInteger secondValue = durationValue % 60;
13751223

13761224
self.slider.minimumValue = 0;
13771225
self.slider.maximumValue = durationValue;
13781226

1379-
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
1227+
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
13801228
weakSelf.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
13811229

13821230
dispatch_source_set_timer(weakSelf.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
@@ -1391,16 +1239,16 @@ - (void)startPlayVideoWithStartTime:(NSInteger )startTime endTime:(NSInteger )en
13911239
//起始时间等于duration
13921240
weakSelf.totalLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",minuteValue,secondValue];
13931241
weakSelf.currentLabel.text = weakSelf.totalLabel.text;
1394-
DDLogDebug(@"over:-----sliderValue:%f---currentTime:%f----totalTime:%f----playduratio:%f",self.slider.value,self.player.currentPlaybackTime,self.player.duration,self.player.playableDuration);
1242+
// DDLogDebug(@"over:-----sliderValue:%f---currentTime:%f----totalTime:%ld----playduratio:%f",self.slider.value,self.player.currentPlaybackTime,self.videoTimeModel.EndTime.integerValue - self.videoTimeModel.StartTime.integerValue,self.player.playableDuration);
13951243
});
13961244

13971245
}else{
13981246

13991247
dispatch_async(dispatch_get_main_queue(), ^{
1400-
weakSelf.currentLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",(NSInteger)self.player.currentPlaybackTime/60,(NSInteger)self.player.currentPlaybackTime%60];
1248+
weakSelf.currentLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",(NSInteger)time/60,(NSInteger)time%60];
14011249
weakSelf.totalLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",minuteValue,secondValue];;
14021250
weakSelf.slider.value = time;
1403-
DDLogDebug(@"duration:-----sliderValue:%f---currentTime:%f----totalTime:%f----playduratio:%f",self.slider.value,self.player.currentPlaybackTime,self.player.duration,self.player.playableDuration);
1251+
// DDLogDebug(@"duration:-----sliderValue:%f---currentTime:%f----totalTime:%ld----playduratio:%f",self.slider.value,self.player.currentPlaybackTime,self.videoTimeModel.EndTime.integerValue - self.videoTimeModel.StartTime.integerValue,self.player.playableDuration);
14041252
});
14051253
time++;
14061254

@@ -1487,7 +1335,7 @@ -(void)removeMovieNotificationObservers
14871335
[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMoviePlayerPlaybackDidFinishNotification object:_player];
14881336
[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMoviePlayerPlaybackStateDidChangeNotification object:_player];
14891337
[[NSNotificationCenter defaultCenter]removeObserver:self name:IJKMPMoviePlayerLoadStateDidChangeNotification object:_player];
1490-
[[NSNotificationCenter defaultCenter]removeObserver:self name:@"xp2preconnect" object:nil];
1338+
[[NSNotificationCenter defaultCenter]removeObserver:self name:@"xp2disconnect" object:nil];
14911339
[[NSNotificationCenter defaultCenter] removeObserver:self];
14921340
}
14931341

@@ -1534,6 +1382,18 @@ - (void)stopPlayMovie {
15341382
[self.player.view removeFromSuperview];
15351383
self.player = nil;
15361384
}
1385+
1386+
[self clearPlayerControlView];
1387+
}
1388+
1389+
/// 删除底层image之上的 控制view (slider 总时间/当前时间显示 暂停/播放按钮等控件)
1390+
- (void)clearPlayerControlView {
1391+
if (self.customControlVidwoView != nil) {
1392+
[self.customControlVidwoView removeFromSuperview];
1393+
}
1394+
if (self.playPauseBtn != nil) {
1395+
[self.playPauseBtn removeFromSuperview];
1396+
}
15371397
}
15381398

15391399
#pragma mark - lazy loading

0 commit comments

Comments
 (0)