Repository navigation
Add a Cameras widget for go2rtc and HLS cameras - #22
Open
masonjmiller wants to merge 7 commits into
Open
masonjmiller wants to merge 7 commits into
masonjmiller wants to merge 7 commits into
Conversation
A touchscreen beside the desk is a natural place to keep an eye on the house, and most camera setups that would want one already run go2rtc: Frigate and Home Assistant ship it, and it turns RTSP, ONVIF, HomeKit and the rest into streams anything can play. The widget asks go2rtc for its camera list and plays each camera through go2rtc's HLS endpoint with AVPlayer, so there is nothing else to install and no third-party code. Two layouts: one camera at a time with tabs over the picture, or all of them in a grid where a tap enlarges one. Fill the Tile crops to the card's edges, in the grid too; off, every picture stays whole. Tabs, names and the speaker take the theme's corner radius, the grid takes its widget gap, and the color follows the accent until one is picked for the widget on the Theme page. That last part needed a small addition, defaultsToAccentColor, so the Theme page's swatch shows what the widget actually draws. AVPlayer is built for video on demand: left alone it buffers seconds and drifts further behind with every hiccup. LiveStreamPlayer starts as soon as the stream is ready, jumps back to the live edge when it lags, and rebuilds a stalled stream with backoff. Against go2rtc's half-second segments it runs about two seconds behind the camera, measured against the camera's own clock overlay. Cameras stream only while somebody can see them: not on the neighbouring pages that stay rendered for swiping, and not while the displays sleep. RTSP cameras are not entries of their own. go2rtc's HLS endpoint serves only streams it already has, and keeping RTSP URLs in go2rtc keeps their passwords out of the layout file. HLS URLs can be added directly. Tested on a XENEON EDGE against go2rtc 1.9.14 with three Wyze cameras. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no cameras picked, the list already says it is showing every camera on the server, and the help under it said the same thing again in other words. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 7, 2026
A tile is a glance; sometimes the dog needs a proper look. A tap on any camera, in either layout, now opens it across the whole dashboard, above every page, with controls that fade four seconds after the last touch: close, pause and play, sound when the stream has any, a LIVE or PAUSED badge, and arrows through the widget's other cameras. A tap anywhere else shows or hides the controls; Esc closes. This replaces the grid's enlarge-in-place, which full screen does better. Opening is instant because the picture doesn't reconnect: CameraService now keeps one LiveStreamPlayer per stream, shared by every view showing that camera, which also means one camera on two widgets streams once. The service claims the full-screen camera's stream before the tiles underneath let go of it, and keeps it a second after closing while they take it back; meanwhile the other tiles rest. Pausing holds the picture and stops the download; playing again jumps back to live, and closing leaves the stream live and muted as its tile had it. EdgeControl's own touch handling had no idea of something drawn over the dashboard: the smallest zone under a finger won, so a widget button beneath the camera could take a tap meant for it, and a swipe paged the dashboard behind it. Touch zones now have a layer. While any zone on a higher layer is registered, the ones beneath can't be hit, and the hardware swipe leaves the pages alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tabs, camera names, the speaker, and the full-screen buttons and badge are controls floating on the picture, not boxes on the dashboard, so they're capsules (circles, for the square buttons) even in a square theme. The video itself still takes the card's corners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… picture With Switch Every set, the next camera's stream starts 8 seconds before its turn, and the switch waits until it plays (up to 12 seconds more, then moves on to show what's wrong). Cameras take seconds to start, a Ring live view more than most, so before this every switch showed a spinner first. The early stream goes through the service's shared players, so the tile takes it over as it is. Nothing starts early while the widget is off screen, the displays sleep, a camera is open full screen, or switching is paused after a touch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Cameras widget decides it's off screen, and stops its cameras, when less than half of it is on the dashboard. It compared its frame in the dashboard's coordinates with the dashboard's bounds from GeometryProxy.bounds(of:), which are in the widget's own coordinates, so a widget whose left edge was right of about the middle counted as off screen and stopped three seconds after appearing. Moving or resizing a widget there left it blank for good. Both rectangles are now in the widget's coordinates. Checked against go2rtc: a widget at column 12 of a 2560-point dashboard stopped streaming before and plays on now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey team. I had this idea come to me, since I'm constantly watching my elderly dog sleep during the day while I work from home, so I turned to Claude for help on this one as i'm not a Swift developer.
A native Cameras widget (Media) for live cameras. It plays them from a go2rtc server, the streaming hub that Frigate and Home Assistant already ship, or from any HLS URL.
What it does
A camera opened full screen, with its controls showing: the name and "2 of 3", close, arrows to the other cameras, pause, the LIVE badge and sound:
The widget's settings:
How
Camera lists.
CameraService(ServiceKey.cameras) readsGET /api/streamsthroughCITransport, so its tests useStubTransport. It re-reads each watched server every minute.Playback.
LiveStreamPlayerwraps AVPlayer on go2rtc's/api/stream.m3u8?src=:Against go2rtc's half-second segments it runs about 2 s behind the camera, measured against the camera's own clock overlay. There are no web views and no third-party code.
Pausing holds the picture and stops the download, and playing again jumps back to live.
Shared players.
CameraServicekeeps oneLiveStreamPlayerper stream, shared by every view showing that camera. Each view says whether it wants the stream playing, and it plays while any of them does. That makes full screen instant: it shows the player the tile was already using. The service claims that stream before the tiles underneath let go of it, and keeps it a second after closing while they take it back.Full screen is drawn by
CameraFullScreenLayer, one line in DashboardShell's root ZStack above the focus layer.Settings. A new
ConfigFieldType.cameraList, next tonotePicker/noteStack, rendered byCameraListEditor. It lists the server's cameras to pick from (or "All Cameras"), lets you reorder and remove them, and can add an HLS stream by URL. An empty list means every camera on the server.DashboardWidget.defaultsToAccentColor(defaultfalse) lets a widget default to the theme accent rather than a fixed color. ThemeSettingsView shows the accent as that widget's default swatch, so the two always agree.NSLocalNetworkUsageDescription, because macOS asks before the app reaches cameras on the LAN.No "Opens on Tap": Cameras joins
WidgetLaunch.excluded, since its taps switch cameras and open them full screen.Choices worth a look
layout.json.TouchZonenow has alayer(default 0), andtouchTappabletakes one. While any zone on a higher layer is registered, the ones beneath can't be hit.Testing
xcodebuild testpasses in full: 432 Swift Testing tests in 46 suites and 111 XCTest tests. 45 of the tests are new, in nine suites:go2rtc-streams.jsonis synthetic, shaped like go2rtc 1.9.14's response. It includes a stream named after its source URL, password and all, to prove those are left out of the list.Not in this PR
MJPEG and snapshot cameras, go2rtc API logins, and an optional low-latency WebRTC mode. I'm happy to follow up if any of those are wanted.
🤖 Generated with Claude Code