mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Close websocket on changing camera
This commit is contained in:
parent
ba8fef842b
commit
478d9b2eef
@ -1,11 +1,11 @@
|
||||
import { h } from 'preact';
|
||||
import { baseUrl } from '../api/baseUrl';
|
||||
import { useMemo } from 'preact/hooks';
|
||||
import { useEffect } from 'preact/hooks';
|
||||
|
||||
export default function WebRtcPlayer({ camera, width, height }) {
|
||||
const url = `${baseUrl.replace(/^http/, 'ws')}go2rtc/api/ws?src=${camera}`;
|
||||
|
||||
useMemo(() => {
|
||||
useEffect(() => {
|
||||
const ws = new WebSocket(url);
|
||||
ws.onopen = () => {
|
||||
pc.createOffer().then(offer => {
|
||||
@ -57,6 +57,10 @@ export default function WebRtcPlayer({ camera, width, height }) {
|
||||
// so need to create transeivers manually
|
||||
pc.addTransceiver('video', {direction: 'recvonly'});
|
||||
pc.addTransceiver('audio', { direction: 'recvonly' });
|
||||
|
||||
return () => {
|
||||
ws.close();
|
||||
};
|
||||
}, [url]);
|
||||
|
||||
return (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user