Skip to content

Conversation

@Deni-al
Copy link

@Deni-al Deni-al commented Jan 27, 2026

Adds system media notification support for background playback, allowing users to control video playback from the lock screen, notification shade, and control center.

Features:

  • New NotificationMetadata class for customizing media notification content
  • New notificationMetadata parameter in VideoPlayerOptions to enable notifications
  • updateNotificationMetadata() method for dynamic metadata updates during playback
  • System media controls (play/pause/seek) on lock screen and control center

Platform support:

  • Android: Uses Media3 MediaSession with foreground service
  • iOS/macOS: Uses MPNowPlayingInfoCenter and MPRemoteCommandCenter
  • Web: Not supported (returns false for availability check)

Fixes flutter/flutter#62739

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Adds the ability for video playback to continue when the app is backgrounded,
with optional system media notification controls on Android and iOS/macOS.

Features:
- New `allowBackgroundPlayback` option in `VideoPlayerOptions`
- New `NotificationMetadata` class for customizing media notification
- System media controls (play/pause/seek) on lock screen and control center
- `updateNotificationMetadata()` method for dynamic metadata updates

Platform support:
- Android: Uses Media3 MediaSession with foreground service
- iOS/macOS: Uses MPNowPlayingInfoCenter and MPRemoteCommandCenter
- Web: Not supported (returns false for availability check)
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces background playback with system media notification support for the video_player plugin across Android, iOS, and macOS. The web platform explicitly opts out of this feature. The changes include adding new API methods in video_player_platform_interface for setting and updating notification metadata, as well as platform-specific implementations for Android (using Media3 MediaSession) and iOS/macOS (using MPNowPlayingInfoCenter and MPRemoteCommandCenter). The necessary Pigeon-generated code and test cases have been updated accordingly. Resource cleanup for background playback is also handled during player disposal.

Comment on lines 479 to 481
final VideoPlayerOptions? options = videoPlayerOptions;
final NotificationMetadata? metadata = options?.notificationMetadata;
if (options != null && options.allowBackgroundPlayback) {

Choose a reason for hiding this comment

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

medium

The variables options and metadata are redundant here. You can directly access videoPlayerOptions and videoPlayerOptions?.notificationMetadata within the if condition, making the code slightly more concise.

    if (videoPlayerOptions != null && videoPlayerOptions.allowBackgroundPlayback) {
      await _videoPlayerPlatform.setBackgroundPlayback(
        _playerId,
        enableBackground: true,
        notificationMetadata: videoPlayerOptions.notificationMetadata,
      );
    }

@stuartmorgan-g
Copy link
Collaborator

stuartmorgan-g commented Jan 27, 2026

Thanks for the contribution! This appears to be substantially expanding the scope of video_player (as compared to the existing PR), so the first step here would be a design document that explains the change at a high level, and obtains buy-in from the relevant code owners on having this much background playback UI support in the core plugin.

Setting to Draft status for now, since the design document review should happen before code review.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft January 27, 2026 20:22
Remove setBackgroundPlayback() and isBackgroundPlaybackSupportAvailable()
methods. Background playback is now automatically enabled when
notificationMetadata is provided in VideoPlayerOptions during initialization.
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.

Background Audio capability in video player

2 participants