You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
992B

  1. import {AfterViewInit, Component, ElementRef, ViewChild} from '@angular/core';
  2. import {MatDialogRef} from "@angular/material/dialog";
  3. import {loadPlayer, Player} from "rtsp-relay/browser";
  4. @Component({
  5. selector: 'app-camera-dialog',
  6. templateUrl: './camera-dialog.component.html',
  7. styleUrls: ['./camera-dialog.component.scss']
  8. })
  9. export class CameraDialogComponent implements AfterViewInit{
  10. player?: Player;
  11. videoLoaded: boolean = false;
  12. @ViewChild('videoPlayer') videoPlayer?: ElementRef<HTMLCanvasElement>;
  13. constructor(public dialogRef: MatDialogRef<CameraDialogComponent>) { }
  14. async ngAfterViewInit() {
  15. const connect = async () => {
  16. this.player = await loadPlayer({
  17. url: 'wss://wss.aztrace.vn/stream',
  18. canvas: this.videoPlayer!.nativeElement,
  19. onDisconnect: () => {
  20. setTimeout(connect, 5000);
  21. },
  22. });
  23. this.videoLoaded = true;
  24. };
  25. connect();
  26. }
  27. onClose(): void {
  28. this.dialogRef.close();
  29. }
  30. }