Skip to content

Fix playback state update in PlatformUpdateSource method#3080

Draft
ne0rrmatrix wants to merge 24 commits intoCommunityToolkit:mainfrom
ne0rrmatrix:FixAutoPlay
Draft

Fix playback state update in PlatformUpdateSource method#3080
ne0rrmatrix wants to merge 24 commits intoCommunityToolkit:mainfrom
ne0rrmatrix:FixAutoPlay

Conversation

@ne0rrmatrix
Copy link
Member

Description of Change

Fixes issue where Stopped state triggers when playback is initiated. This restores proper flow for MediaElementState when starting playback.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

Fixes Current State:

Opening
Stopped
Paused
Buffering
Playing

Fixed State:

Opening
Paused
Buffering
Playing

Copilot AI review requested due to automatic review settings February 9, 2026 15:45
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 aims to fix an Android MediaElement state-transition issue where Stopped is raised when playback starts (notably with AutoPlay), restoring the expected MediaElementState flow when setting/updating the source.

Changes:

  • Moves MediaElement.CurrentStateChanged(MediaElementState.Opening) so it only fires when a MediaItem is available (right before SetMediaItem / Prepare).

Refactored OnPlayerStateChanged to use AndroidX.Media3.Common.BasePlayer.InterfaceConsts for state mapping instead of deprecated PlaybackState values.
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

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

…oid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 10, 2026 03:53
ne0rrmatrix and others added 2 commits February 9, 2026 19:54
…oid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…oid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Refactored OnPlayerStateChanged to use AndroidX.Media3.Common.BasePlayer.InterfaceConsts for state mapping instead of deprecated PlaybackState values. Updated state checks and switch logic for improved clarity and compatibility with the newer Media3 API.
Copilot AI review requested due to automatic review settings February 10, 2026 05:07
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

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

ne0rrmatrix and others added 2 commits February 9, 2026 21:12
…oid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 10, 2026 05:14
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

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

…oid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 10, 2026 05:23
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Refactored mapping of playback states to MediaElementState, including improved handling for Idle and Opening states. Added MediaFailed event notification in OnPlayerErrorChanged. Removed unused PlaybackState static class and constants.
@ne0rrmatrix ne0rrmatrix requested a review from Copilot February 10, 2026 05:38
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.

…oid.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 10, 2026 05:50
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

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

Copilot AI review requested due to automatic review settings February 11, 2026 05:29
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

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

Copilot AI review requested due to automatic review settings February 11, 2026 11:57
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings February 17, 2026 11:31
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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

@ne0rrmatrix ne0rrmatrix marked this pull request as draft March 21, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Android implementation of MediaElement raises unexpected Stopped state change when playing using AutoPlay

2 participants