Skip to content

Fix iOS MediaElement support for multiple ItemsViews and windows - #3222

Merged
TheCodeTraveler merged 14 commits into
CommunityToolkit:mainfrom
ne0rrmatrix:FixItemsViewController
Oct 6, 2026
Merged

TheCodeTraveler merged 14 commits into
CommunityToolkit:mainfrom
ne0rrmatrix:FixItemsViewController

Conversation

@ne0rrmatrix

Copy link
Copy Markdown
Member

Summary

  • fix MediaElement parent view controller attachment on iOS/MacCatalyst by resolving the actual UIKit responder-chain parent instead of guessing from page/item view state
  • add shared current-page enumeration across windows to support multi-window scenarios
  • add unit coverage for multi-window page resolution in ParentWindowTests

Why

MediaElement was throwing in templated iOS/MacCatalyst scenarios when:

  • a page contained multiple ItemsView controls
  • an app used multiple windows

Using the actual rendered UIKit hierarchy avoids the brittle handler-selection logic that caused both failures.

Fixes #2247
Fixes #2249

Validation

  • ran focused MediaElement unit tests (ParentWindowTests, MediaElementTests): 14 passed
  • verified in the simulator

Copilot AI review requested due to automatic review settings May 21, 2026 06:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes iOS/MacCatalyst MediaElement failures in templated and multi-window scenarios by attaching AVPlayerViewController using the actual UIKit responder-chain parent view controller (instead of inferring it from MAUI page/items-view state), and adds shared helpers/tests for resolving current pages across multiple windows.

Changes:

  • Update iOS/MacCatalyst MauiMediaElement to attach/detach AVPlayerViewController based on the UIKit responder chain (supporting multiple ItemsViews and multiple windows).
  • Add a shared TryGetCurrentPages helper to enumerate the “current page” per window.
  • Add unit coverage validating multi-window current-page resolution.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/CommunityToolkit.Maui.UnitTests/Views/MediaElement/ParentWindowTests.cs Adds a unit test asserting current-page resolution across multiple windows.
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.macios.cs Reworks iOS/MacCatalyst parent view controller attachment logic to use the UIKit responder chain.
src/CommunityToolkit.Maui.MediaElement/Extensions/PageExtensions.shared.cs Adds multi-window current-page enumeration and updates parent-window current-page resolution.

@dotnet-policy-service dotnet-policy-service Bot added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels Jun 23, 2026
MediaManager.macios.cs: take main (keeps CommunityToolkit#3281 fields incl. hasMediaOpened)
and re-add the PR's ShowsPlaybackControls line in CreatePlatformView.
MauiMediaElement.macios.cs: take the PR's responder-chain version.
PageExtensions.shared.cs: main's layout with the PR's CurrentPage expression.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@TheCodeTraveler TheCodeTraveler removed help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days labels Oct 2, 2026
@TheCodeTraveler
TheCodeTraveler requested a balanced review from Copilot October 2, 2026 01:40
@TheCodeTraveler TheCodeTraveler self-assigned this Oct 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Child view controllers must be detached during disposal, and the unused page-enumeration path should be removed or integrated.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
Resolved since last review (2)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Multi-window coverage is missing and an existing null-platform-view test no longer exercises its intended branch.

Review effort: Balanced
Findings: 1 Medium severity · 4 Low severity

Open (5)
Resolved since last review (1)

@TheCodeTraveler
TheCodeTraveler merged commit 3a0bdce into CommunityToolkit:main Oct 6, 2026
4 of 5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

3 participants