mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Set url outside onEffect
This commit is contained in:
parent
89adc958cd
commit
0e91b78780
@ -1,17 +1,12 @@
|
|||||||
import { h } from 'preact';
|
import { h } from 'preact';
|
||||||
|
import { baseUrl } from '../api/baseUrl';
|
||||||
import { useEffect } from 'preact/hooks';
|
import { useEffect } from 'preact/hooks';
|
||||||
|
|
||||||
export default function WebRtcPlayer({ camera, width, height }) {
|
export default function WebRtcPlayer({ camera, width, height }) {
|
||||||
|
const url = `${baseUrl.replace(/^http/, 'ws')}go2rtc/api/ws?src=${camera}`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let ws;
|
const ws = new WebSocket(url);
|
||||||
|
|
||||||
if (location.protocol == 'https:') {
|
|
||||||
ws = new WebSocket(`wss://${window.location.host}/go2rtc/api/ws?src=${camera}`);
|
|
||||||
} else {
|
|
||||||
ws = new WebSocket(`ws://${window.location.host}/go2rtc/api/ws?src=${camera}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
pc.createOffer().then(offer => {
|
pc.createOffer().then(offer => {
|
||||||
pc.setLocalDescription(offer).then(() => {
|
pc.setLocalDescription(offer).then(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user