Commit b26ca851 by Sweet Zhang

视频播放接口对接

parent a6cfaf59
...@@ -14,9 +14,10 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -14,9 +14,10 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
permissions: any; permissions: any;
lifeCustomerInfo: any; lifeCustomerInfo: any;
timer: any; timer: any;
timer2:any; timer2: any;
videoPlaybacks: Array<any>; videoPlaybacks: Array<any>;
originTime: number = 0; originTime: number = 0;
fileId:string;
constructor(private activatedRoute: ActivatedRoute, private myService: MyService) { } constructor(private activatedRoute: ActivatedRoute, private myService: MyService) { }
ngOnInit() { ngOnInit() {
...@@ -24,9 +25,17 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -24,9 +25,17 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
this.permissions = JSON.parse(sessionStorage.getItem('permissions')); this.permissions = JSON.parse(sessionStorage.getItem('permissions'));
this.pdfPath = this.activatedRoute.snapshot.queryParams['path']; this.pdfPath = this.activatedRoute.snapshot.queryParams['path'];
this.lifeCustomerInfo = JSON.parse(localStorage.getItem('lifeCustomerInfo')); this.lifeCustomerInfo = JSON.parse(localStorage.getItem('lifeCustomerInfo'));
this.fileId = this.activatedRoute.snapshot.params['fileId']
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.saveVideoPlayback() this.saveVideoPlayback();
}, 1000 * 20) }, 1000 * 20)
this.timer2 = setInterval(()=>{
if (this.video.nativeElement.currentTime - this.originTime > 1) {
this.video.nativeElement.currentTime = this.originTime;
// this.video.nativeElement.pause();
}
this.originTime = this.video.nativeElement.currentTime;
},500)
this.queryVideoPlayback() this.queryVideoPlayback()
} }
...@@ -35,32 +44,20 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -35,32 +44,20 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
console.log('暂停播放') console.log('暂停播放')
this.saveVideoPlayback(); this.saveVideoPlayback();
}); });
// 禁止拖动进度条
this.timer2 = setInterval(()=> {
const currentTime = this.video.nativeElement.currentTime;
const originTime = Number(sessionStorage.getItem('curTime')) ;
if (currentTime - originTime > 1) {
this.video.nativeElement.currentTime = sessionStorage.getItem('curTime')
this.video.nativeElement.pause();
sessionStorage.setItem('curTime',currentTime)
}
}, 500)
// >>>>>>>>>>>>>禁止拖动进度条结束<<<<<<<<<<<<<<
const attr = this.video.nativeElement.getAttribute('controlslist')
if (this.permissions.isDownload == '2') { if (this.permissions.isDownload == '2') {
this.video.nativeElement.setAttribute('controlslist', attr + ' nodownload') this.video.nativeElement.setAttribute('controlslist', this.video.nativeElement.getAttribute('controlslist') + ' nodownload')
} else { } else {
this.video.nativeElement.setAttribute('controlslist', attr) this.video.nativeElement.setAttribute('controlslist', this.video.nativeElement.getAttribute('controlslist'))
} }
if (this.permissions.isControlPlayback == '2') { if (this.permissions.isControlPlayback == '2') {
this.video.nativeElement.setAttribute('controlslist', attr + ' noplaybackrate') this.video.nativeElement.setAttribute('controlslist', this.video.nativeElement.getAttribute('controlslist') + ' noplaybackrate')
} else { } else {
this.video.nativeElement.setAttribute('controlslist', attr) this.video.nativeElement.setAttribute('controlslist', this.video.nativeElement.getAttribute('controlslist'))
} }
} }
ngOnDestroy(): void { ngOnDestroy(): void {
clearInterval(this.timer) clearInterval(this.timer);
clearInterval(this.timer2) clearInterval(this.timer2);
this.saveVideoPlayback(); this.saveVideoPlayback();
} }
menuPrevent() { menuPrevent() {
...@@ -72,12 +69,11 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -72,12 +69,11 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
id: '', id: '',
customerId: this.lifeCustomerInfo.customerId, customerId: this.lifeCustomerInfo.customerId,
practitionerId: this.lifeCustomerInfo.practitionerId, practitionerId: this.lifeCustomerInfo.practitionerId,
fileId: '', fileId: this.fileId,
totalTime: this.video.nativeElement.duration, totalTime: this.video.nativeElement.duration,
viewTime: this.video.nativeElement.currentTime, viewTime: this.video.nativeElement.currentTime,
playbackStatus: this.video.nativeElement.currentTime >= this.video.nativeElement.duration ? 2 : 1, playbackStatus: this.video.nativeElement.currentTime >= this.video.nativeElement.duration ? 2 : 1,
} }
sessionStorage.setItem('curTime',this.video.nativeElement.currentTime);
this.myService.saveVideoPlayback(param).subscribe(res => { this.myService.saveVideoPlayback(param).subscribe(res => {
console.log(res); console.log(res);
}) })
...@@ -88,7 +84,7 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -88,7 +84,7 @@ export class VideoComponent implements OnInit, AfterViewInit, OnDestroy {
id: '', id: '',
customerId: this.lifeCustomerInfo.customerId, customerId: this.lifeCustomerInfo.customerId,
practitionerId: this.lifeCustomerInfo.practitionerId, practitionerId: this.lifeCustomerInfo.practitionerId,
fileId: '', fileId: this.fileId,
} }
this.myService.queryVideoPlayback(param).subscribe(res => { this.myService.queryVideoPlayback(param).subscribe(res => {
if (res['success']) { if (res['success']) {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<i class="iconfont icon-xiazai" style="margin-right: 0;"></i> <i class="iconfont icon-xiazai" style="margin-right: 0;"></i>
</div> </div>
</a> </a>
<a href="javascript:;" [routerLink]="['/video']" *ngIf="judgmentFile(fileUploadItem.filePath)" (click)="setVideoPath(fileUploadItem)"> <a href="javascript:;" [routerLink]="['/video',{'fileId':fileUploadItem.fileId}]" *ngIf="judgmentFile(fileUploadItem.filePath)" (click)="setVideoPath(fileUploadItem)">
<div style="overflow-x: hidden; white-space: nowrap;text-overflow: ellipsis;"> <div style="overflow-x: hidden; white-space: nowrap;text-overflow: ellipsis;">
<img src="assets/images/videoIcon.png" alt="视频" *ngIf="judgmentFile(fileUploadItem.filePath)" style=" width: 26px; <img src="assets/images/videoIcon.png" alt="视频" *ngIf="judgmentFile(fileUploadItem.filePath)" style=" width: 26px;
margin-right: 6px;"> margin-right: 6px;">
......
...@@ -53,7 +53,6 @@ export class FileUploadComponent implements OnInit { ...@@ -53,7 +53,6 @@ export class FileUploadComponent implements OnInit {
this.selectedCategoryId = 'requirementanalys' this.selectedCategoryId = 'requirementanalys'
} }
this.fileUpload(3, 0, 23, 'yd_trainning_file_type', this.selectedCategoryId); this.fileUpload(3, 0, 23, 'yd_trainning_file_type', this.selectedCategoryId);
console.log(this.activatedRoute.snapshot)
} }
} }
// 判断是不是视频文件 // 判断是不是视频文件
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment