diff --git a/src/app/play/play.component.ts b/src/app/play/play.component.ts index e8ca84fd9241b2d48e294a24fcdb422bed2c2d46..2f91561072347adb71445a3035401d689e375c9e 100644 --- a/src/app/play/play.component.ts +++ b/src/app/play/play.component.ts @@ -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() {