Skip to content

feat(ui): show HLS livestreams in picture in picture - #1796

Draft
renefloor wants to merge 3 commits into
feat/hls-uifrom
feat/hls-pip
Draft

renefloor wants to merge 3 commits into
feat/hls-uifrom
feat/hls-pip

Conversation

@renefloor

Copy link
Copy Markdown
Contributor

🎯 Goal

Step 8 of HLS_PLAN.md (FLU-1266): picture in picture for HLS livestreams on Android and iOS. Web PiP waits until it can line up with #1763. Stacked on #1795.

🛠 Implementation details

  • Android
    • On HLS, LivestreamHlsContent hosts StreamPictureInPictureAndroidView and uses the HLS video builder as the window's content. An app's own callPictureInPictureWidgetBuilder still takes precedence.
    • StreamHlsVideoRenderer reports its video size to RenderedVideoSizes under hlsVideoTrackId(callCid), and the PiP view uses that id on HLS. The window takes the stream's shape and animates in from where the video is drawn.
    • The new package:stream_video_flutter/hls.dart exports both for stream_video_hls.
  • iOS
    • LivestreamHlsVideoProperties.enablePictureInPicture is passed to StreamHlsVideoRenderer(enablePictureInPicture:), which calls setPictureInPictureEnabled over the channel.
    • The player adds an AVPlayerLayer on the same AVPlayer to the key window at 1 pt, since the controller needs a layer in the window hierarchy.
    • From that layer it creates an AVPictureInPictureController with requiresLinearPlayback, set to start automatically from inline playback.
    • Requests are counted per renderer, so the window goes away once no renderer asks for it.
    • With no key window yet, it waits for one.
    • It answers pip_unsupported on devices without PiP and logs a start that fails.
    • Apps need the audio background mode.

🧪 Testing

  • New Android test: on HLS, the PiP window takes the HLS video's aspect ratio, also with a custom builder. All PiP and livestream tests pass.
  • The example's integration tests pass on the Android emulator and the iOS simulator.
  • iOS PiP is not verified. iOS 27 simulators report isPictureInPictureSupported() == false (checked on the iPhone Duo and iPhone 17 Pro simulators), so the example's PiP test skips there. It needs a check on a physical device: play, then background the app.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the v2 label Dec 4, 2026
@getstream-metis

Copy link
Copy Markdown

👋 Hi Rene, still cooking? 🍳

I'm Jeffery, Stream's review agent. I look for bugs, regressions, missing tests and slow paths, and I only post findings I've checked against the code.

📝 This PR is a draft, so I'll keep my hands off for now. Mark it Ready for review and a ✅ box to start my review shows up right here.

Can't wait? Comment /jeffery review now and I'll start the moment it's ready. I'll stay quiet unless you ask.

renefloor and others added 3 commits December 5, 2026 10:59
On Android, the HLS branch of the livestream UI hosts the picture-in-picture
view with the HLS video as the window's content. `StreamHlsVideoRenderer`
reports its video size under an HLS id, which the view uses on HLS, so the
window takes the stream's shape and animates in from where it is drawn.

On iOS, `StreamHlsVideoRenderer(enablePictureInPicture: true)`, which the
livestream UI passes from its picture-in-picture configuration, adds a
player layer on the same AVPlayer to the key window and starts an
AVPictureInPictureController from it when the app goes to the background.
iOS simulators do not support picture in picture, so this is not verified
yet; the example's test skips there.

`package:stream_video_flutter/hls.dart` exports what stream_video_hls needs
for this. Picture in picture on web waits for the web work in #1763.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Count the renderers that ask for picture in picture, and withdraw a
  renderer's request when it is disposed, so the window no longer opens
  for a player no screen shows, and two renderers on one player share it.
- Set picture in picture up once a window becomes key when there is none
  yet, instead of dropping the request.
- Answer `pip_unsupported` on a device without picture in picture, which
  the renderer logs, and log a window that fails to start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant