mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Use onEffect
This commit is contained in:
parent
ae89e817a2
commit
89adc958cd
@ -1,8 +1,11 @@
|
|||||||
import { h } from 'preact';
|
import { h } from 'preact';
|
||||||
|
import { useEffect } from 'preact/hooks';
|
||||||
|
|
||||||
let ws;
|
export default function WebRtcPlayer({ camera, width, height }) {
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let ws;
|
||||||
|
|
||||||
function initStream(camera) {
|
|
||||||
if (location.protocol == 'https:') {
|
if (location.protocol == 'https:') {
|
||||||
ws = new WebSocket(`wss://${window.location.host}/go2rtc/api/ws?src=${camera}`);
|
ws = new WebSocket(`wss://${window.location.host}/go2rtc/api/ws?src=${camera}`);
|
||||||
} else {
|
} else {
|
||||||
@ -59,10 +62,8 @@ function initStream(camera) {
|
|||||||
// so need to create transeivers manually
|
// so need to create transeivers manually
|
||||||
pc.addTransceiver('video', {direction: 'recvonly'});
|
pc.addTransceiver('video', {direction: 'recvonly'});
|
||||||
pc.addTransceiver('audio', {direction: 'recvonly'});
|
pc.addTransceiver('audio', {direction: 'recvonly'});
|
||||||
}
|
}, [camera]);
|
||||||
|
|
||||||
export default function WebRtcPlayer({ camera, width, height }) {
|
|
||||||
initStream(camera);
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<video id='video' autoplay playsinline controls muted width={width} height={height} />
|
<video id='video' autoplay playsinline controls muted width={width} height={height} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user