Commit d7b04e05 authored by liujiaxin's avatar liujiaxin

add video cover

parent 098bb6b0
......@@ -44,14 +44,16 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
// 获取数据
const getData = ( window as any).courseware.getData;
getData((data) => {
console.log(111, data);
console.log(222, data);
if (data && typeof data === 'object') {
this.data = data;
}
this.hasVideo = !!this.data.contentObj.video_url;
window["air"].hideAirClassLoading(this.saveKey, this.data);
this.ngAfterDataInit();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
window["air"].hideAirClassLoading(this.saveKey, this.data);
}, this.saveKey);
......@@ -66,8 +68,11 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
ngOnChanges(data) {
}
ngAfterViewInit() {
}
ngAfterDataInit() {
if (!this.videoNodeRef) {
return;
}
......@@ -94,11 +99,16 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
};
this.player.addEventListener("ended", () => {
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
})
setTimeout(() => {
this.initCover = this.data.contentObj.pic_id;
});
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
playVideo() {
......@@ -106,7 +116,7 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
return;
}
if (!this.player) {
this.ngAfterViewInit();
this.ngAfterDataInit();
}
if (!this.player) {
return;
......@@ -125,6 +135,8 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
} else {
this.player.pause();
}
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
......@@ -135,15 +147,24 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
this.progress = Math.floor((player.currentTime / player.duration) * 100);
console.log(this.progress);
this.duration = this.player.duration;
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
onBtnQuickSeek(delta: number) {
this.player.currentTime += delta;
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
onProgressMouseDown(event) {
this.player.pause();
this.touchSeeking = true;
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
onProgressMouseMove(event) {
......@@ -151,11 +172,17 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges, AfterViewIni
const {target, offsetX} = event;
this.progress = Math.floor(offsetX / target.clientWidth * 100);
}
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
onProgressMouseUp(event) {
const {target, offsetX} = event;
this.player.currentTime = this.player.duration * offsetX / target.clientWidth;
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
refresh() {
......
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