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