Update live page

test
dan 2020-03-23 20:10:59 -06:00
parent a2edf88fb1
commit 6f26bb859d
2 changed files with 34 additions and 39 deletions

View File

@ -1,9 +1,14 @@
<secondary-page-component [hideSideBarOnMobile]="true" > <secondary-page-component [hideSideBarOnMobile]="true" >
<div mainContent class="mapWrapper"> <div mainContent class="mapWrapper">
<div class="video-container"> <h2 *ngIf="!showVideo">{{message}}</h2>
<h1 *ngIf="!showVideo">{{message}}</h1> <div class="video-container" *ngIf="showVideo">
<video [class.opacity-zero]="!showVideo" *ngIf="!error" style="width:100%" [src]="videoSrc" controls [poster]="poster" (error)="vidError()"></video> <video [class.opacity-zero]="!showVideo" *ngIf="!error" style="width:100%" [src]="videoSrc" controls [poster]="poster" (error)="vidError()"></video>
</div> </div>
<div style="margin-top: 10px">
<button routerLink="/video" style="margin-top:5px; width:100%;" mat-stroked-button>
<b><i ofbicon style="margin-top:-4px; vertical-align: middle;">play_arrow</i> Click here for previous video services</b>
</button>
</div>
</div> </div>
<div sideBar ofbFadeInOnScroll> <div sideBar ofbFadeInOnScroll>

View File

@ -29,46 +29,36 @@ export class LiveStreamComponent implements OnInit {
private interval; private interval;
ngOnInit() { ngOnInit() {
this.update();
this.interval = setInterval(() => { this.interval = setInterval(() => {
this.http.get<VideoServices>('assets/json/videoServices.json').subscribe(res => { this.update();
res.videos = res.videos.filter(v => v.archived === false); }, 3000);
res.videos.forEach(v => v.date = DateTime.fromISO(v.date, {zone: 'America/Denver'}));
res.videos.sort((a, b) => {
if (a.date < b.date) return -1;
if (a.date === b.date) return 0;
return 1;
});
var service = res.videos[0];
if (service) {
this.message = (<any>service).message;
if (service.isReady === true) {
this.showVideo = true;
this.videoSrc = '';
this.videoSrc = service.src;
clearInterval(this.interval);
}
} else {
this.message = 'No Live Services';
}
});
}, 3000);
} }
public async vidError() { update() {
console.log('err'); this.http.get<VideoServices>('assets/json/videoServices.json').subscribe(res => {
return; res.videos = res.videos.filter(v => v.archived === false);
if (this.videoSrc === '') return; res.videos.forEach(v => v.date = DateTime.fromISO(v.date, {zone: 'America/Denver'}));
this.error = true; res.videos.sort((a, b) => {
setTimeout(async () => { if (a.date < b.date) return -1;
this.error = false; if (a.date === b.date) return 0;
setTimeout(() => { return 1;
if (!this.error) { });
var service = res.videos[0];
if (service) {
this.message = (<any>service).message;
if (service.isReady === true) {
this.showVideo = true; this.showVideo = true;
this.videoSrc = '';
this.videoSrc = service.src;
clearInterval(this.interval);
} }
}, 3000); } else {
}, 3000); this.message = 'No Live Services';
}
});
} }
} }