Streamedian / html5_rtsp_player

Play RTSP stream from IP camera in browser in this HTML5 player without plugins
Apache License 2.0
2.61k stars 598 forks source link

Angular 7 Intergation, Connects To Proxy But Gets No Video Back #109

Open Skid-Inc opened 5 years ago

Skid-Inc commented 5 years ago

I've been trying to get your player working within Angular 7, and finally got Angular to not throw errors relating to constructors or methods not existing and it looks like it does connect to the proxy successfully, but I've not getting any video data back from it. The stream I know is fine as I've tested both the ones I've used with the basic html/js implementation from your examples folder and it connects and displays.

app.component.html

<video id="test_video" controls autoplay></video>

app.component.ts

import { Component, AfterViewInit, OnDestroy } from '@angular/core';

import * as streamedian from 'streamedian/src/player.js';
import WebsocketTransport from 'streamedian/src/transport/websocket.js';
import RTSPClient from 'streamedian/src/client/rtsp/client.js';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewInit, OnDestroy {

  private mediaElement: any;
  private streamPlayer: any;

  errHandler = function(err) {
    alert(err.message);
  };

  ngAfterViewInit() {
    /*this.streamPlayer = new WSPlayer('test_video', {
      socket: 'ws://192.168.1.85:8080/ws/',
      redirectNativeMediaErrors: true,
      bufferDuration: 30,
      errorHandler: this.errHandler
    });*/
    this.mediaElement = document.getElementById('test_video');
    this.streamPlayer = new streamedian.WSPlayer(this.mediaElement, {
      // url: 'rtsp://syno:5b4cdf54e0063fec8e88f3c7c269c6cb@192.168.1.2:554/Sms=1.unicast',
      url: 'rtsp://b1.dnsdojo.com:1935/live/sys3.stream',
      type: streamedian.StreamType.RTSP,
      modules: [
        {
          client: RTSPClient,
          transport: {
            constructor: WebsocketTransport,
            options: {
              socket: 'ws://localhost:8080/ws/'
            }
          }
        }
      ]
    });

    /* this.streamPlayer.setSource(
      'rtsp://syno:5b4cdf54e0063fec8e88f3c7c269c6cb@192.168.1.2:554/Sms=1.unicast',
      streamedian.StreamType.RTSP
    );*/
  }

  ngOnDestroy() {
    this.streamPlayer.stop();
    this.streamPlayer.destroy();
    this.streamPlayer = null;
  }
}

Console log can be found here: https://pastebin.com/zXmyGrV5

Any advice would be appreciated, I'm using v7.2.0 of Angular.

ricastro commented 5 years ago

Did you managed to find a solution?

Skid-Inc commented 5 years ago

Not directly, I bypassed the problem by making the component call an iframe with the basic javascript version in it. Which is not good design from an Angular SPA perspective.