Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am trying to use it with Angular but always getting error like A.match is not a function. I gave it a div element but still throws error. #26

Open
Aditya-Ace opened this issue May 18, 2020 · 3 comments

Comments

@Aditya-Ace
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@Aditya-Ace
Copy link
Author

Aditya-Ace commented May 18, 2020

Code:
@ViewChild('streamContainer', { static: true, read: ElementRef })
streamContainer: ElementRef;
ngAfterViewInit(): void {
// Setup the WebSocket connection and start the player
const client = new WebSocket('ws://localhost:9999/');
new JSMpeg.VideoElement(this.streamContainer.nativeElement, client);
}
It does not work...

@cycjimmy
Copy link
Owner

Code:
@ViewChild('streamContainer', { static: true, read: ElementRef })
streamContainer: ElementRef;
ngAfterViewInit(): void {
// Setup the WebSocket connection and start the player
const client = new WebSocket('ws://localhost:9999/');
new JSMpeg.VideoElement(this.streamContainer.nativeElement, client);
}
It does not work...

The second parameter supports a URL. you can directly use the address of WebSocket.

...
- const client = new WebSocket('ws://localhost:9999/');
- new JSMpeg.VideoElement(this.streamContainer.nativeElement, client);
+ const url = 'ws://localhost:9999/';
+ new JSMpeg.VideoElement(this.streamContainer.nativeElement, url);
...

@Aditya-Ace
Copy link
Author

Thank you so much for your response:
Now I am trying the process in a lil different way:

iPstreaming = () => {
const url = environment.webSocketApi;
new JSMpeg.VideoElement(this.canvas1.nativeElement, url);
// const player = new jsmpeg(client, {
// canvas: this.canvas1.nativeElement,
// autoplay: true,
// loop: true,
// });
const stream = this.canvas1.nativeElement.captureStream(30);
this.ipVideoElement.nativeElement.srcObject = stream;
this.window.nativeWindow.stream = stream;
this.startIPCamRecordingBtn.nativeElement.removeAttribute('disabled');
};

the frame keeps on loading, no visuals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants