Skip to content

feat!: Add PlayingStateUpdate event#1995

Merged
Gustl22 merged 56 commits into
mainfrom
gustl22/playingStateUpdate
Jul 22, 2026
Merged

feat!: Add PlayingStateUpdate event#1995
Gustl22 merged 56 commits into
mainfrom
gustl22/playingStateUpdate

Conversation

@Gustl22

@Gustl22 Gustl22 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Description

Introduce PlayingStateUpdate event. This has the following advantages:

  • If the player is stopped by the system (another native source than AP itself), the state change is reflected in the Dart's player state.
  • Recognize the actual moment, when a player starts / stops (this was sometimes not correct, as buffering or processing took place first)
  • await playing actions, until they are finshed (e.g. awaits play, until player is actually playing, awaits stop / pause, until the player actually stops)
  • Tests should now be much more consistent / robust (as long as it affects the playback / events).

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, refactor:,
    docs:, chore:, test:, ci: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation and added dartdoc comments with ///, where necessary.
  • I have updated/added relevant examples in example.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Again, this is not a hard breaking change, but in this case, the behavior actually changes:

  • resume / play are waiting, until the playback actually has started
  • stop / pause are waiting, until the playback actually stops
  • playback starts / stops, when the native player is controlled from outside the app, e.g. via system controls.

Migration instructions

Before:

Federated plugin implementations didn't consider playing state updates (resume / pause).

After:

Federated plugin implementations need to consider playing state updates (resume / pause).

@Gustl22
Gustl22 marked this pull request as draft June 7, 2026 05:21
@Gustl22
Gustl22 marked this pull request as ready for review June 8, 2026 19:55
@Gustl22
Gustl22 marked this pull request as draft June 9, 2026 00:55
@Gustl22
Gustl22 marked this pull request as ready for review June 18, 2026 12:28
@Gustl22
Gustl22 force-pushed the gustl22/playingStateUpdate branch 2 times, most recently from 62b3cb4 to 1e2ab4b Compare July 9, 2026 06:51
@Gustl22
Gustl22 force-pushed the gustl22/playingStateUpdate branch 2 times, most recently from 5165bc0 to 76a33a7 Compare July 20, 2026 22:23
@Gustl22
Gustl22 force-pushed the gustl22/playingStateUpdate branch from 76a33a7 to bc76ef5 Compare July 21, 2026 21:10
@Gustl22 Gustl22 changed the title feat: Add PlayingStateUpdate event feat!: Add PlayingStateUpdate event Jul 21, 2026
Comment thread packages/audioplayers/lib/src/audioplayer.dart
@Gustl22
Gustl22 requested a review from spydon July 21, 2026 21:58

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

Adds a new cross-platform playingStateUpdate event and wires it through Dart + all federated implementations so AudioPlayer can reflect externally-triggered play/pause changes and reliably await play/pause/stop transitions based on actual playback state.

Changes:

  • Introduces AudioEventType.playingStateUpdate (+ isPlaying) and maps native events to it across platform implementations.
  • Updates AudioPlayer to track “desired vs actual” state and wait for playing-state transitions with a timeout.
  • Adjusts unit + integration tests to account for the new event ordering and more deterministic state transitions.

Reviewed changes

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

Show a summary per file
File Description
packages/audioplayers/test/fake_audioplayers_platform.dart Emits playingStateUpdate events in the fake platform for state-affecting calls.
packages/audioplayers/test/audioplayers_test.dart Updates expectations for dispose/event ordering with the new playing-state behavior.
packages/audioplayers/test/audio_pool_test.dart Awaits async stop to align with new stop semantics.
packages/audioplayers/lib/src/audioplayer.dart Implements desired-vs-actual state tracking and awaits playing-state transitions.
packages/audioplayers/example/pubspec.yaml Removes pub_semver dev dependency from example.
packages/audioplayers/example/integration_test/platform_test.dart Simplifies platform test gating and removes old Flutter-version workaround.
packages/audioplayers/example/integration_test/lib_test.dart Makes integration assertions more robust with updated state/position expectations; adds “call twice” tests.
packages/audioplayers_windows/windows/MediaEngineWrapper.h Adds playing-state callback wiring in Windows media engine wrapper.
packages/audioplayers_windows/windows/MediaEngineWrapper.cpp Emits audio.onPlayingStateUpdate on PLAYING/PAUSE media engine events.
packages/audioplayers_windows/windows/audio_player.h Declares Windows OnPlayingStateUpdate handler.
packages/audioplayers_windows/windows/audio_player.cpp Sends audio.onPlayingStateUpdate events over the Windows event channel.
packages/audioplayers_web/lib/wrapped_player.dart Emits playingStateUpdate from HTML audio play/pause events.
packages/audioplayers_platform_interface/lib/src/audioplayers_platform.dart Maps audio.onPlayingStateUpdate to the new AudioEventType.
packages/audioplayers_platform_interface/lib/src/api/audio_event.dart Adds playingStateUpdate type and isPlaying field on AudioEvent.
packages/audioplayers_linux/linux/audio_player.h Declares Linux OnPlayingStateUpdate.
packages/audioplayers_linux/linux/audio_player.cc Emits audio.onPlayingStateUpdate on GStreamer paused/playing transitions.
packages/audioplayers_darwin/darwin/audioplayers_darwin/Sources/audioplayers_darwin/WrappedMediaPlayer.swift Observes AVPlayer timeControlStatus to emit playing-state updates.
packages/audioplayers_darwin/darwin/audioplayers_darwin/Sources/audioplayers_darwin/AudioplayersDarwinPlugin.swift Adds stream handler method to forward audio.onPlayingStateUpdate.
packages/audioplayers_android/android/src/main/kotlin/xyz/luan/audioplayers/player/WrappedPlayer.kt Adds Android callback entrypoint for playing-state updates.
packages/audioplayers_android/android/src/main/kotlin/xyz/luan/audioplayers/player/SoundPoolPlayer.kt Emits playing-state updates for SoundPool actions.
packages/audioplayers_android/android/src/main/kotlin/xyz/luan/audioplayers/player/MediaPlayerWrapper.kt Manually emits playing-state updates for MediaPlayer operations lacking suitable callbacks.
packages/audioplayers_android/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt Sends audio.onPlayingStateUpdate events from Android plugin.
packages/audioplayers_android_exo/android/src/main/kotlin/xyz/luan/audioplayers/player/WrappedPlayer.kt Adds Exo callback entrypoint for playing-state updates.
packages/audioplayers_android_exo/android/src/main/kotlin/xyz/luan/audioplayers/player/ExoPlayerWrapper.kt Hooks onIsPlayingChanged to emit playing-state updates.
packages/audioplayers_android_exo/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt Sends audio.onPlayingStateUpdate events from Android Exo plugin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/audioplayers/lib/src/audioplayer.dart Outdated
Comment thread packages/audioplayers/lib/src/audioplayer.dart Outdated
Comment thread packages/audioplayers/lib/src/audioplayer.dart Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Gustl22
Gustl22 marked this pull request as draft July 22, 2026 05:44
Gustl22 and others added 4 commits July 22, 2026 07:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Gustl22
Gustl22 marked this pull request as ready for review July 22, 2026 05:49

@spydon spydon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, good idea!

@Gustl22
Gustl22 enabled auto-merge (squash) July 22, 2026 10:28
@Gustl22
Gustl22 merged commit fa6ec8e into main Jul 22, 2026
110 of 114 checks passed
@Gustl22
Gustl22 deleted the gustl22/playingStateUpdate branch July 22, 2026 11:29
Sebastien-VZN pushed a commit to Sebastien-VZN/audioplayers that referenced this pull request Jul 23, 2026
Commits marqués comme analyses et non portes:
- 310304d ci: Upgrade CI Flutter version to v3.44.6 (bluefireteam#2014) — cosmétique CI
- 244a4a0 ci: Support verbose debugging in tests (bluefireteam#2015) — cosmétique CI
- 0b89829 test: Set timeouts for integration tests (bluefireteam#2016) — cosmétique tests
- 6efd636 refactor: Handle common ReleaseMode.release logic in Dart (bluefireteam#2017) — redondant, deja gere nativement
- fa6ec8e feat!: Add PlayingStateUpdate event (bluefireteam#1995) — over-engineering, 500 lignes pour rien
- cd475c7 fix(windows): Crash Windows N Media Feature Pack (bluefireteam#2019) — try-catch global du fork couvre deja le cas
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.

3 participants