* Unified status + frame query - the single source of truth for broadcast state. * Returns broadcast state and the latest frame in one call. * Works on both mobile (iOS/Android) and desktop (macOS/Windows/Linux).
()
| 1393 | * Works on both mobile (iOS/Android) and desktop (macOS/Windows/Linux). |
| 1394 | */ |
| 1395 | async getStatus(): Promise<BroadcastStatus> { |
| 1396 | if (!isTauri()) { |
| 1397 | // Return safe defaults when not in Tauri |
| 1398 | return { |
| 1399 | isActive: false, |
| 1400 | isStale: false, |
| 1401 | frame: null, |
| 1402 | timestamp: null, |
| 1403 | frameCount: 0, |
| 1404 | }; |
| 1405 | } |
| 1406 | |
| 1407 | try { |
| 1408 | const result = await invoke<BroadcastStatus>('get_broadcast_status'); |
| 1409 | return result; |
| 1410 | } catch (error) { |
| 1411 | console.error("[ScreenCapture]", error); |
| 1412 | // Return safe defaults on error |
| 1413 | return { |
| 1414 | isActive: false, |
| 1415 | isStale: false, |
| 1416 | frame: null, |
| 1417 | timestamp: null, |
| 1418 | frameCount: 0, |
| 1419 | }; |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | isCapturing(): boolean { |
| 1424 | return this.capturing; |