* 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).
()
| 1415 | * Works on both mobile (iOS/Android) and desktop (macOS/Windows/Linux). |
| 1416 | */ |
| 1417 | async getStatus(): Promise<BroadcastStatus> { |
| 1418 | if (!isTauri()) { |
| 1419 | // Return safe defaults when not in Tauri |
| 1420 | return { |
| 1421 | isActive: false, |
| 1422 | isStale: false, |
| 1423 | frame: null, |
| 1424 | timestamp: null, |
| 1425 | frameCount: 0, |
| 1426 | }; |
| 1427 | } |
| 1428 | |
| 1429 | try { |
| 1430 | const result = await invoke<BroadcastStatus>('get_broadcast_status'); |
| 1431 | return result; |
| 1432 | } catch (error) { |
| 1433 | console.error("[ScreenCapture]", error); |
| 1434 | // Return safe defaults on error |
| 1435 | return { |
| 1436 | isActive: false, |
| 1437 | isStale: false, |
| 1438 | frame: null, |
| 1439 | timestamp: null, |
| 1440 | frameCount: 0, |
| 1441 | }; |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | isCapturing(): boolean { |
| 1446 | return this.capturing; |