доработка README
This commit is contained in:
@@ -18,8 +18,6 @@ export function initCamera(): void {
|
||||
camImage = document.getElementById("camImage") as HTMLImageElement;
|
||||
crosshair = document.getElementById("crosshair");
|
||||
|
||||
// Проверяем доступность потока
|
||||
checkStreamAvailability();
|
||||
|
||||
const btn = document.getElementById("camToggle");
|
||||
|
||||
@@ -37,6 +35,7 @@ export function initCamera(): void {
|
||||
// Показываем перекрестие
|
||||
if (crosshair) {
|
||||
crosshair.style.display = "block";
|
||||
crosshair.style.opacity = "0.5";
|
||||
}
|
||||
|
||||
if (camImage) {
|
||||
@@ -114,29 +113,6 @@ export function initCamera(): void {
|
||||
|
||||
btn?.addEventListener("click", toggle);
|
||||
|
||||
// Проверка доступности камеры
|
||||
async function checkStreamAvailability(): Promise<void> {
|
||||
try {
|
||||
const response = await fetch('/api/stream');
|
||||
const data: StreamResponse = await response.json();
|
||||
|
||||
if (data.available && data.cam) {
|
||||
console.log("[camera] stream available:", data.source);
|
||||
// Автозапуск если камера доступна
|
||||
if (!isOpen) {
|
||||
open();
|
||||
}
|
||||
} else {
|
||||
console.log("[camera] stream not available");
|
||||
if (crosshair) {
|
||||
crosshair.style.display = 'none';
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("[camera] check failed:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Мониторинг состояния потока
|
||||
function startStreamMonitoring(): void {
|
||||
stopStreamMonitoring();
|
||||
|
||||
Reference in New Issue
Block a user