Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Summary

Enables audio playback in the native WebRTC video player and adds mute/unmute controls. The previous implementation had audio disabled via useManualAudio = true to avoid microphone permission requests.

Key changes:

  • Audio session configuration: Uses AVAudioSession.Category.playback for receive-only audio (no microphone access required)
  • Remote audio track management: Properly extracts audio track from peer connection transceivers after remote SDP is set
  • Mute/unmute UI: Added button at bottom-left of player using SF Symbols (speaker.wave.fill / speaker.slash.fill)
  • State synchronization: ViewModel mute state always reflects actual audio track state

Technical details:

// Audio session configured for playback only
audioSession.setCategory(AVAudioSession.Category.playback.rawValue)
audioSession.setMode(AVAudioSession.Mode.spokenAudio.rawValue)

// Remote audio track extracted after SDP negotiation
remoteAudioTrack = peerConnection.transceivers
    .first(where: { $0.mediaType == .audio })?
    .receiver.track as? RTCAudioTrack

The implementation removes microphone-related warnings from the experimental disclaimer.

Screenshots

N/A - Audio feature, no visual changes beyond the mute button icon which follows existing control patterns.

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Audio mode uses .spokenAudio for optimal voice/camera audio playback. The mute button follows the same auto-hide behavior as other player controls (3-second timeout).

Original prompt

Let's start supporting audio on WebRTCVideoPlayerView, including control mute/unmute


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add audio support and mute/unmute controls to WebRTCVideoPlayerView Add audio support to WebRTC video player with mute/unmute controls Dec 10, 2025
Copilot AI requested a review from bgoncal December 10, 2025 15:16
Refactored WebRTCVideoPlayerViewControls to group top buttons and improve mute button styling, including conditional glass effect for iOS 26+. Updated ModalCloseButton to use glass effect when available. Simplified AVAudioSession category/mode usage in WebRTCClient. Shortened the experimental disclaimer string.
@bgoncal bgoncal marked this pull request as ready for review December 10, 2025 15:47
Copilot AI review requested due to automatic review settings December 10, 2025 15:47
@bgoncal bgoncal enabled auto-merge (squash) December 10, 2025 15:47
@@ -1,4 +1,4 @@
"WebRTC_player.experimental.disclaimer" = "Note: Native WebRTC video player is currently an experimental feature, audio may not work and microphone permission and usage may be requested even though not in use. Please use the web player interface for advanced options and reliable playback.";
Copy link
Member

Choose a reason for hiding this comment

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

This change will be reverted by Lokalise. But at this moment it's fine, the current copy is better for the moment in time.

Copy link
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

This PR adds audio playback support to the native WebRTC video player with mute/unmute controls. The previous implementation had audio disabled to avoid microphone permission requests. The implementation properly configures the audio session for receive-only playback, extracts the remote audio track after SDP negotiation, and provides UI controls for muting/unmuting.

Key changes:

  • Audio session configured for playback-only mode (.playback category with .spokenAudio mode) to receive audio without requiring microphone access
  • Remote audio track management added with proper extraction from peer connection transceivers after remote SDP is set
  • Mute/unmute button added to video player controls with iOS 26.0+ glass effect styling

Reviewed changes

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

Show a summary per file
File Description
Sources/App/WebView/WebRTC/WebRTCClient.swift Adds audio session configuration, remote audio track management, and mute/unmute methods
Sources/App/WebView/WebRTC/WebRTCViewPlayerViewModel.swift Adds isMuted state and toggleMute() method for audio control
Sources/App/WebView/WebRTC/WebRTCVideoPlayerViewControls.swift Adds mute/unmute button with speaker icons to player controls
Sources/App/WebView/WebRTC/WebRTCVideoPlayerView.swift Integrates mute state and toggle action into controls view
Sources/Shared/DesignSystem/Components/ModalCloseButton.swift Adds iOS 26.0+ glass effect styling with conditional padding
Sources/Shared/Resources/Swiftgen/Strings.swift Updates experimental disclaimer text to remove microphone-related warnings
Sources/App/Resources/en.lproj/Localizable.strings Updates experimental disclaimer localization string

@bgoncal bgoncal merged commit cd86bc3 into main Dec 10, 2025
10 checks passed
@bgoncal bgoncal deleted the copilot/add-audio-support-webrtc-player branch December 10, 2025 16:34
@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@d29319d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...red/DesignSystem/Components/ModalCloseButton.swift 0.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4074   +/-   ##
=======================================
  Coverage        ?   45.75%           
=======================================
  Files           ?      242           
  Lines           ?    13628           
  Branches        ?        0           
=======================================
  Hits            ?     6236           
  Misses          ?     7392           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants