Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 6.8.0

* Adds `preventsDisplaySleepDuringVideoPlayback` to `VideoPlayerOptions` and
`setPreventsDisplaySleepDuringVideoPlayback` to `VideoPlayerPlatform`.
Comment thread
tarrinneal marked this conversation as resolved.
Resolved
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

## 6.7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ abstract class VideoPlayerPlatform extends PlatformInterface {
throw UnimplementedError('setAllowBackgroundPlayback() has not been implemented.');
}

/// Sets whether the screen is prevented from sleeping during video playback.
Future<void> setPreventsDisplaySleepDuringVideoPlayback(
int playerId,
bool preventsDisplaySleepDuringVideoPlayback,
) {
throw UnimplementedError(

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.

Sorry, I missed this in the previous review. It looks like the main PR plans to only implement this for some platforms.

A feature cannot both throw an error when not implemented, and not have a support query, because otherwise there is no way for a client to know whether or not it is safe to call the method.

Is the desired behavior for this feature that it silently no-ops if not implemented, or do clients need to know whether it is going to work?

/cc @tarrinneal

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

switched the default to a silent no-op.

'setPreventsDisplaySleepDuringVideoPlayback() has not been implemented.',
);
}

/// Sets additional options on web.
Future<void> setWebOptions(int playerId, VideoPlayerWebOptions options) {
throw UnimplementedError('setWebOptions() has not been implemented.');
Expand Down Expand Up @@ -461,6 +471,7 @@ class VideoPlayerOptions {
VideoPlayerOptions({
this.mixWithOthers = false,
this.allowBackgroundPlayback = false,
this.preventsDisplaySleepDuringVideoPlayback = true,
this.webOptions,
});

Expand All @@ -475,6 +486,13 @@ class VideoPlayerOptions {
/// currently no way to implement this feature in this platform).
final bool mixWithOthers;

/// Whether the screen is prevented from sleeping during video playback.
///
/// Defaults to `true`.
///
/// This option may not be supported on all platforms.
final bool preventsDisplaySleepDuringVideoPlayback;

/// Additional web controls
final VideoPlayerWebOptions? webOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/video_player/
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 6.7.0
version: 6.8.0

environment:
sdk: ^3.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ void main() {
final options = VideoPlayerOptions();
expect(options.mixWithOthers, false);
});
test('VideoPlayerOptions preventsDisplaySleepDuringVideoPlayback defaults to true', () {
final options = VideoPlayerOptions();
expect(options.preventsDisplaySleepDuringVideoPlayback, true);
});
}