[video_player_platform_interface] Add preventsDisplaySleepDuringVideoPlayback option#11546
Conversation
There was a problem hiding this comment.
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.
| * Adds `preventsDisplaySleepDuringVideoPlayback` to `VideoPlayerOptions` and | ||
| `setPreventsDisplaySleepDuringVideoPlayback` to `VideoPlayerPlatform`. |
There was a problem hiding this comment.
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.
| * 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. |
| Future<void> setPreventsDisplaySleepDuringVideoPlayback( | ||
| int playerId, | ||
| bool preventsDisplaySleepDuringVideoPlayback, | ||
| ) { | ||
| return Future<void>.value(); | ||
| } |
There was a problem hiding this comment.
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.
| 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
fbf1314 to
c52b4b6
Compare
Description
Adds the
preventsDisplaySleepDuringVideoPlaybackfield toVideoPlayerOptionsand asetPreventsDisplaySleepDuringVideoPlaybackmethod toVideoPlayerPlatform, allowing platform implementations to control whether the display sleeps during video playback.Platform interface breakout PR for #11225.
Changes
preventsDisplaySleepDuringVideoPlaybackfield toVideoPlayerOptions(defaults totrueto preserve existing behavior).setPreventsDisplaySleepDuringVideoPlayback(int playerId, bool preventsDisplaySleepDuringVideoPlayback)method toVideoPlayerPlatformwith a default no-op implementation so existing platform implementations continue to compile without changes.preventsDisplaySleepDuringVideoPlayback.Related