Skip to content

Add ExoPlayer support for FrontendScreen from frontend request#6771

Merged
jpelgrom merged 10 commits intomainfrom
feature/exoplayer
May 5, 2026
Merged

Add ExoPlayer support for FrontendScreen from frontend request#6771
jpelgrom merged 10 commits intomainfrom
feature/exoplayer

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Apr 24, 2026

Summary

This PR adds support for showing exoPlayer from a frontend command on the FrontendScreen.
I've introduced a ExoPlayerOverlay to manage the player, once the player is initialized for the session we keep it so it can be reuse. I've also introduced a way to request full screen to the activity, it is also use to request leaving full screen but if the settings is already set to full screen then it stays on full screen.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Screenshots

Screen_recording_20260429_125650.mp4

@TimoPtr TimoPtr force-pushed the feature/exoplayer branch from b782ecc to e92f0fa Compare April 29, 2026 08:21
@TimoPtr TimoPtr force-pushed the feature/fullscreen branch from 1b1d943 to 66f08d1 Compare April 29, 2026 08:21
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

Test Results

  248 files  + 6    256 suites  +6   10m 46s ⏱️ + 1m 19s
1 879 tests +36  1 879 ✅ +36  0 💤 ±0  0 ❌ ±0 
1 944 runs  +36  1 944 ✅ +36  0 💤 ±0  0 ❌ ±0 

Results for commit 271b455. ± Comparison against base commit 66f08d1.

♻️ This comment has been updated with latest results.

@TimoPtr TimoPtr marked this pull request as ready for review April 29, 2026 10:57
@TimoPtr TimoPtr requested a review from jpelgrom April 29, 2026 10:57
Base automatically changed from feature/fullscreen to main April 29, 2026 20:55
@TimoPtr TimoPtr force-pushed the feature/exoplayer branch from 271b455 to 97481e4 Compare April 30, 2026 10:04
Copilot AI review requested due to automatic review settings April 30, 2026 10:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ExoPlayer-backed video playback support to the Compose FrontendScreen via new typed external bus messages, including a fullscreen request pathway up to LaunchActivity.

Changes:

  • Introduces new incoming external bus messages (exoplayer/play_hls, exoplayer/resize, exoplayer/stop) and corresponding handler events.
  • Adds a FrontendExoPlayerManager + ExoPlayerUiState, wires it into FrontendViewModel/FrontendViewState, and renders via a new ExoPlayerOverlay in FrontendScreen.
  • Adds a FrontendEvent.RequestFullscreen flow from frontend screen → navigation → LaunchViewModel to control system bars, plus tests.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
app/src/main/kotlin/io/homeassistant/companion/android/frontend/externalbus/incoming/IncomingExternalBusMessage.kt Adds typed incoming external bus messages for ExoPlayer commands
app/src/main/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendMessageHandler.kt Maps new incoming messages to handler events and sends result for play_hls
app/src/main/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendHandlerEvent.kt Adds ExoPlayer action event types
app/src/main/kotlin/io/homeassistant/companion/android/frontend/exoplayer/FrontendExoPlayerManager.kt New manager to own ExoPlayer lifecycle and overlay sizing/fullscreen state
app/src/main/kotlin/io/homeassistant/companion/android/frontend/exoplayer/ExoPlayerUiState.kt UI state model for overlay position/size/fullscreen/aspect ratio
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewState.kt Adds exoPlayerState to FrontendViewState.Content
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt Collects ExoPlayer state into viewState, handles ExoPlayer actions, emits fullscreen requests
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt Renders HAMediaPlayer overlay positioned by frontend resize messages
app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendEvent.kt Adds RequestFullscreen event type
app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendNavigation.kt Threads onRequestFullscreen through navigation and handles the new event
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HAApp.kt Adds optional onRequestFullscreen plumbing into app scaffold
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HANavHost.kt Passes onRequestFullscreen into frontend navigation graph
app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt Wires fullscreen requests from nav/UI into LaunchViewModel
app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchViewModel.kt Combines fullscreen preference with temporary fullscreen requests
app/src/test/kotlin/io/homeassistant/companion/android/frontend/externalbus/incoming/IncomingExternalBusMessageTest.kt Tests JSON decoding for new ExoPlayer messages
app/src/test/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendMessageHandlerTest.kt Tests handler behavior for ExoPlayer messages
app/src/test/kotlin/io/homeassistant/companion/android/frontend/exoplayer/FrontendExoPlayerManagerTest.kt New unit tests for manager behavior
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt Tests fullscreen/event emission and ExoPlayer action forwarding/cleanup
app/src/test/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendEventHandlerTest.kt Adds coverage for RequestFullscreen event handling
app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchViewModelTest.kt Adds tests for preference/request fullscreen combining

@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label Apr 30, 2026
@TimoPtr TimoPtr requested a review from Copilot April 30, 2026 12:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ExoPlayer-driven video playback to the Compose FrontendScreen based on Home Assistant frontend external-bus commands, including overlay rendering and fullscreen coordination with the host activity’s fullscreen preference handling.

Changes:

  • Add new incoming external-bus message types (exoplayer/play_hls, exoplayer/resize, exoplayer/stop) and route them into new FrontendHandlerEvent.ExoPlayerAction events.
  • Introduce FrontendExoPlayerManager + ExoPlayerUiState and wire it into FrontendViewModel/FrontendViewState to render a HAMediaPlayer overlay.
  • Add a FrontendEvent.RequestFullscreen pipeline from FrontendViewModel → navigation host → LaunchViewModel, combining frontend requests with the user’s fullscreen preference.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchViewModel.kt Combine user fullscreen preference with temporary fullscreen requests from the frontend
app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt Wire onRequestFullscreen callback into the Compose app host
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HAApp.kt Thread onRequestFullscreen callback through app scaffold to navigation host
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/HANavHost.kt Pass onRequestFullscreen into the frontend navigation setup
app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendNavigation.kt Add onRequestFullscreen handler plumbing and handle FrontendEvent.RequestFullscreen
app/src/main/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendEvent.kt Introduce RequestFullscreen one-shot event
app/src/main/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendHandlerEvent.kt Add ExoPlayerAction events used to drive playback/resize/stop
app/src/main/kotlin/io/homeassistant/companion/android/frontend/externalbus/incoming/IncomingExternalBusMessage.kt Add incoming external-bus message models for ExoPlayer commands
app/src/main/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendMessageHandler.kt Parse ExoPlayer external-bus messages and emit corresponding handler events
app/src/main/kotlin/io/homeassistant/companion/android/frontend/exoplayer/FrontendExoPlayerManager.kt New manager owning ExoPlayer instance, resize/aspect-ratio logic, and state flow
app/src/main/kotlin/io/homeassistant/companion/android/frontend/exoplayer/ExoPlayerUiState.kt New UI state model for the overlay player (position/size/fullscreen/aspect ratio)
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewState.kt Extend Content state to include ExoPlayer overlay state
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModel.kt Integrate ExoPlayer manager lifecycle, forward actions, and emit fullscreen requests
app/src/main/kotlin/io/homeassistant/companion/android/frontend/FrontendScreen.kt Render ExoPlayer overlay on top of WebView using HAMediaPlayer
app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchViewModelTest.kt Add tests for preference-vs-request fullscreen behavior
app/src/test/kotlin/io/homeassistant/companion/android/frontend/navigation/FrontendEventHandlerTest.kt Add tests ensuring RequestFullscreen events call the host callback
app/src/test/kotlin/io/homeassistant/companion/android/frontend/handler/FrontendMessageHandlerTest.kt Add tests for ExoPlayer message handling via external bus
app/src/test/kotlin/io/homeassistant/companion/android/frontend/externalbus/incoming/IncomingExternalBusMessageTest.kt Add JSON parsing tests for new ExoPlayer message types
app/src/test/kotlin/io/homeassistant/companion/android/frontend/exoplayer/FrontendExoPlayerManagerTest.kt New unit tests for ExoPlayer manager behavior (play/resize/stop/fullscreen/close)
app/src/test/kotlin/io/homeassistant/companion/android/frontend/FrontendViewModelTest.kt Add tests for fullscreen requests, manager wiring, and lifecycle cleanup

Copy link
Copy Markdown
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict to resolve.

@TimoPtr TimoPtr force-pushed the feature/exoplayer branch from fc46f0d to 39035e3 Compare May 5, 2026 10:38
@TimoPtr TimoPtr requested a review from jpelgrom May 5, 2026 10:38
@jpelgrom jpelgrom merged commit c84d7f4 into main May 5, 2026
39 of 40 checks passed
@jpelgrom jpelgrom deleted the feature/exoplayer branch May 5, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants