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.

31 lines
821B

  1. import {Component, OnInit, ViewChild, ElementRef, AfterViewInit, Renderer2} from '@angular/core';
  2. import {loadPlayer, Player} from "rtsp-relay/browser";
  3. @Component({
  4. selector: 'app-camera-stream',
  5. templateUrl: './camera-stream.component.html',
  6. styleUrls: ['./camera-stream.component.scss']
  7. })
  8. export class CameraStreamComponent implements OnInit, AfterViewInit{
  9. player?: Player;
  10. @ViewChild('videoPlayer')
  11. videoPlayer?: ElementRef<HTMLCanvasElement>;
  12. ngOnInit() {
  13. }
  14. constructor(private el: ElementRef, private renderer: Renderer2) {}
  15. async ngAfterViewInit() {
  16. this.player = await loadPlayer({
  17. url: 'ws://localhost:8081',
  18. canvas: this.videoPlayer!.nativeElement,
  19. onDisconnect: () => console.log('Connection lost!'),
  20. });
  21. console.log('Connected!', this.player);
  22. }
  23. }