Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 2.11.1

* Implements screen auto-lock control for video playback.
* Optimizes caption retrieval with binary search.

## 2.11.0
Expand Down
5 changes: 5 additions & 0 deletions packages/video_player/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ flutter:
- assets/bumble_bee_captions.srt
- assets/bumble_bee_captions.vtt
- assets/Audio.mp3
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
video_player_avfoundation: {path: ../../../../packages/video_player/video_player_avfoundation}
video_player_platform_interface: {path: ../../../../packages/video_player/video_player_platform_interface}
7 changes: 7 additions & 0 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,13 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
_creatingCompleter!.complete(null);
final initializingCompleter = Completer<void>();

if (videoPlayerOptions != null) {
await _videoPlayerPlatform.setPreventsDisplaySleepDuringVideoPlayback(
_playerId,
videoPlayerOptions!.preventsDisplaySleepDuringVideoPlayback,
);
}

// Apply the web-specific options
if (kIsWeb && videoPlayerOptions?.webOptions != null) {
await _videoPlayerPlatform.setWebOptions(
Expand Down
7 changes: 7 additions & 0 deletions packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ dev_dependencies:
topics:
- video
- video-player

Choose a reason for hiding this comment

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

medium

According to the repository style guide, temporary dependency_overrides should be accompanied by a comment to prevent them from being merged. Please add the comment # FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. before the dependency_overrides: block.

References
  1. The repository style guide states that temporary dependency_overrides sections in pubspec.yaml files should include a comment starting with 'FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.' to prevent accidental merging. This override is missing the required comment. (link)

# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
video_player_avfoundation: {path: ../../../packages/video_player/video_player_avfoundation}
video_player_platform_interface: {path: ../../../packages/video_player/video_player_platform_interface}

23 changes: 23 additions & 0 deletions packages/video_player/video_player/test/video_player_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,21 @@ void main() {
expect(controller.videoPlayerOptions!.mixWithOthers, true);
});

test('setPreventsDisplaySleepDuringVideoPlayback', () async {
final controller = VideoPlayerController.networkUrl(
_localhostUri,
videoPlayerOptions: VideoPlayerOptions(preventsDisplaySleepDuringVideoPlayback: true),
);
addTearDown(controller.dispose);

await controller.initialize();
expect(controller.videoPlayerOptions!.preventsDisplaySleepDuringVideoPlayback, true);
expect(
fakeVideoPlayerPlatform.calls.contains('setPreventsDisplaySleepDuringVideoPlayback'),
true,
);
});

test('true allowBackgroundPlayback continues playback', () async {
final controller = VideoPlayerController.networkUrl(
_localhostUri,
Expand Down Expand Up @@ -2227,6 +2242,14 @@ class FakeVideoPlayerPlatform extends VideoPlayerPlatform {
calls.add('setMixWithOthers');
}

@override
Future<void> setPreventsDisplaySleepDuringVideoPlayback(
int playerId,
bool preventsDisplaySleepDuringVideoPlayback,
) async {
calls.add('setPreventsDisplaySleepDuringVideoPlayback');
}

@override
Widget buildView(int playerId) {
return Texture(textureId: playerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ flutter:
assets:
- assets/flutter-mark-square-64.png
- assets/Butterfly-209.mp4
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
video_player_platform_interface: {path: ../../../../packages/video_player/video_player_platform_interface}
4 changes: 4 additions & 0 deletions packages/video_player/video_player_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ dev_dependencies:
topics:
- video
- video-player
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
video_player_platform_interface: {path: ../../../packages/video_player/video_player_platform_interface}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.9.5

* Implements screen auto-lock control for video playback.

## 2.9.4

* Ensures that the display link does not continue requesting frames after a player is disposed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ - (void)selectAudioTrackAtIndex:(NSInteger)trackIndex
}
}

- (void)setPreventsDisplaySleepDuringVideoPlayback:(BOOL)preventsDisplaySleepDuringVideoPlayback error:(FlutterError *_Nullable *_Nonnull)error {
if (@available(iOS 12.0, macOS 10.14, *)) {
self.player.preventsDisplaySleepDuringVideoPlayback = preventsDisplaySleepDuringVideoPlayback;
}
}

#pragma mark - Private

- (int64_t)duration {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.7), do not edit directly.
// Autogenerated from Pigeon (v26.2.3), do not edit directly.
// See also: https://pub.dev/packages/pigeon

@import Foundation;
Expand All @@ -22,41 +22,42 @@ NS_ASSUME_NONNULL_BEGIN
@interface FVPPlatformVideoViewCreationParams : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithPlayerId:(NSInteger)playerId;
@property(nonatomic, assign) NSInteger playerId;
+ (instancetype)makeWithPlayerId:(NSInteger )playerId;
@property(nonatomic, assign) NSInteger playerId;
@end

@interface FVPCreationOptions : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithUri:(NSString *)uri
httpHeaders:(NSDictionary<NSString *, NSString *> *)httpHeaders;
@property(nonatomic, copy) NSString *uri;
@property(nonatomic, copy) NSDictionary<NSString *, NSString *> *httpHeaders;
httpHeaders:(NSDictionary<NSString *, NSString *> *)httpHeaders;
@property(nonatomic, copy) NSString * uri;
@property(nonatomic, copy) NSDictionary<NSString *, NSString *> * httpHeaders;
@end

@interface FVPTexturePlayerIds : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithPlayerId:(NSInteger)playerId textureId:(NSInteger)textureId;
@property(nonatomic, assign) NSInteger playerId;
@property(nonatomic, assign) NSInteger textureId;
+ (instancetype)makeWithPlayerId:(NSInteger )playerId
textureId:(NSInteger )textureId;
@property(nonatomic, assign) NSInteger playerId;
@property(nonatomic, assign) NSInteger textureId;
@end

/// Raw audio track data from AVMediaSelectionOption (for HLS streams).
@interface FVPMediaSelectionAudioTrackData : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithIndex:(NSInteger)index
displayName:(nullable NSString *)displayName
languageCode:(nullable NSString *)languageCode
isSelected:(BOOL)isSelected
commonMetadataTitle:(nullable NSString *)commonMetadataTitle;
@property(nonatomic, assign) NSInteger index;
@property(nonatomic, copy, nullable) NSString *displayName;
@property(nonatomic, copy, nullable) NSString *languageCode;
@property(nonatomic, assign) BOOL isSelected;
@property(nonatomic, copy, nullable) NSString *commonMetadataTitle;
+ (instancetype)makeWithIndex:(NSInteger )index
displayName:(nullable NSString *)displayName
languageCode:(nullable NSString *)languageCode
isSelected:(BOOL )isSelected
commonMetadataTitle:(nullable NSString *)commonMetadataTitle;
@property(nonatomic, assign) NSInteger index;
@property(nonatomic, copy, nullable) NSString * displayName;
@property(nonatomic, copy, nullable) NSString * languageCode;
@property(nonatomic, assign) BOOL isSelected;
@property(nonatomic, copy, nullable) NSString * commonMetadataTitle;
@end

/// The codec used by all APIs.
Expand All @@ -65,25 +66,17 @@ NSObject<FlutterMessageCodec> *FVPGetMessagesCodec(void);
@protocol FVPAVFoundationVideoPlayerApi
- (void)initialize:(FlutterError *_Nullable *_Nonnull)error;
/// @return `nil` only when `error != nil`.
- (nullable NSNumber *)createPlatformViewPlayerWithOptions:(FVPCreationOptions *)params
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSNumber *)createPlatformViewPlayerWithOptions:(FVPCreationOptions *)params error:(FlutterError *_Nullable *_Nonnull)error;
/// @return `nil` only when `error != nil`.
- (nullable FVPTexturePlayerIds *)
createTexturePlayerWithOptions:(FVPCreationOptions *)creationOptions
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable FVPTexturePlayerIds *)createTexturePlayerWithOptions:(FVPCreationOptions *)creationOptions error:(FlutterError *_Nullable *_Nonnull)error;
- (void)setMixWithOthers:(BOOL)mixWithOthers error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSString *)fileURLForAssetWithName:(NSString *)asset
package:(nullable NSString *)package
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSString *)fileURLForAssetWithName:(NSString *)asset package:(nullable NSString *)package error:(FlutterError *_Nullable *_Nonnull)error;
@end

extern void SetUpFVPAVFoundationVideoPlayerApi(
id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api);
extern void SetUpFVPAVFoundationVideoPlayerApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api);

extern void SetUpFVPAVFoundationVideoPlayerApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api, NSString *messageChannelSuffix);

extern void SetUpFVPAVFoundationVideoPlayerApiWithSuffix(
id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api, NSString *messageChannelSuffix);

@protocol FVPVideoPlayerInstanceApi
- (void)setLooping:(BOOL)looping error:(FlutterError *_Nullable *_Nonnull)error;
Expand All @@ -96,17 +89,13 @@ extern void SetUpFVPAVFoundationVideoPlayerApiWithSuffix(
- (void)pauseWithError:(FlutterError *_Nullable *_Nonnull)error;
- (void)disposeWithError:(FlutterError *_Nullable *_Nonnull)error;
/// @return `nil` only when `error != nil`.
- (nullable NSArray<FVPMediaSelectionAudioTrackData *> *)getAudioTracks:
(FlutterError *_Nullable *_Nonnull)error;
- (void)selectAudioTrackAtIndex:(NSInteger)trackIndex
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSArray<FVPMediaSelectionAudioTrackData *> *)getAudioTracks:(FlutterError *_Nullable *_Nonnull)error;
- (void)selectAudioTrackAtIndex:(NSInteger)trackIndex error:(FlutterError *_Nullable *_Nonnull)error;
- (void)setPreventsDisplaySleepDuringVideoPlayback:(BOOL)preventsDisplaySleepDuringVideoPlayback error:(FlutterError *_Nullable *_Nonnull)error;
@end

extern void SetUpFVPVideoPlayerInstanceApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPVideoPlayerInstanceApi> *_Nullable api);
extern void SetUpFVPVideoPlayerInstanceApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPVideoPlayerInstanceApi> *_Nullable api);

extern void SetUpFVPVideoPlayerInstanceApiWithSuffix(
id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPVideoPlayerInstanceApi> *_Nullable api,
NSString *messageChannelSuffix);
extern void SetUpFVPVideoPlayerInstanceApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPVideoPlayerInstanceApi> *_Nullable api, NSString *messageChannelSuffix);

NS_ASSUME_NONNULL_END
Loading