Skip to content

[video_player_platform_interface] Add preventsDisplaySleepDuringVideoPlayback option#11546

Open
shrabanti722 wants to merge 1 commit intoflutter:mainfrom
shrabanti722:video-player-prevents-display-sleep-interface
Open

[video_player_platform_interface] Add preventsDisplaySleepDuringVideoPlayback option#11546
shrabanti722 wants to merge 1 commit intoflutter:mainfrom
shrabanti722:video-player-prevents-display-sleep-interface

Conversation

@shrabanti722
Copy link
Copy Markdown

Description

Adds the preventsDisplaySleepDuringVideoPlayback field to VideoPlayerOptions and a setPreventsDisplaySleepDuringVideoPlayback method to VideoPlayerPlatform, allowing platform implementations to control whether the display sleeps during video playback.

Platform interface breakout PR for #11225.

Changes

  • Adds preventsDisplaySleepDuringVideoPlayback field to VideoPlayerOptions (defaults to true to preserve existing behavior).
  • Adds setPreventsDisplaySleepDuringVideoPlayback(int playerId, bool preventsDisplaySleepDuringVideoPlayback) method to VideoPlayerPlatform with a default no-op implementation so existing platform implementations continue to compile without changes.
  • Updates CHANGELOG (6.7.0) and pubspec version.
  • Adds unit test covering the default value of preventsDisplaySleepDuringVideoPlayback.

Related

Copy link
Copy Markdown

@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 updates the video_player_platform_interface to version 6.7.0, adding preventsDisplaySleepDuringVideoPlayback to VideoPlayerOptions and a corresponding method to VideoPlayerPlatform. Review feedback suggests restoring a removed CHANGELOG entry regarding SDK versions and ensuring the new interface method throws an UnimplementedError for consistency with existing methods.

Comment on lines +3 to +4
* Adds `preventsDisplaySleepDuringVideoPlayback` to `VideoPlayerOptions` and
`setPreventsDisplaySleepDuringVideoPlayback` to `VideoPlayerPlatform`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The previous entry regarding the minimum supported SDK version update (Flutter 3.35/Dart 3.9) was removed. It should be preserved in the 6.7.0 section along with the new changes to maintain a complete history of changes.

Suggested change
* Adds `preventsDisplaySleepDuringVideoPlayback` to `VideoPlayerOptions` and
`setPreventsDisplaySleepDuringVideoPlayback` to `VideoPlayerPlatform`.
* Adds `preventsDisplaySleepDuringVideoPlayback` to `VideoPlayerOptions` and
`setPreventsDisplaySleepDuringVideoPlayback` to `VideoPlayerPlatform`.
* Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.

Comment on lines +128 to +133
Future<void> setPreventsDisplaySleepDuringVideoPlayback(
int playerId,
bool preventsDisplaySleepDuringVideoPlayback,
) {
return Future<void>.value();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency with other methods in this class (such as setMixWithOthers, setAllowBackgroundPlayback, and setWebOptions), this method should throw an UnimplementedError instead of returning a no-op Future. This ensures that platform implementations are explicitly notified if they haven't implemented the method when it's called, rather than failing silently.

Suggested change
Future<void> setPreventsDisplaySleepDuringVideoPlayback(
int playerId,
bool preventsDisplaySleepDuringVideoPlayback,
) {
return Future<void>.value();
}
Future<void> setPreventsDisplaySleepDuringVideoPlayback(
int playerId,
bool preventsDisplaySleepDuringVideoPlayback,
) {
throw UnimplementedError(
'setPreventsDisplaySleepDuringVideoPlayback() has not been implemented.',
);
}

…Playback option

Adds the `preventsDisplaySleepDuringVideoPlayback` field to
`VideoPlayerOptions` and a `setPreventsDisplaySleepDuringVideoPlayback`
method to `VideoPlayerPlatform`, allowing platform implementations to
control whether the display sleeps during video playback.

Platform interface breakout PR for flutter#11225.

Made-with: Cursor
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.

[video_player] Allow screen auto-lock during video playback on iOS

1 participant