-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[video_player] #60048 ios picture in picture #3500
base: main
Are you sure you want to change the base?
[video_player] #60048 ios picture in picture #3500
Conversation
@hellohuanlin & @stuartmorgan I did the migration from flutter/plugins#6284 to here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
carrying over the stamp from previous PR
@tarrinneal can I assist you with the review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial pass. A few changes to be made. Good work on this!
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_platform_interface/CHANGELOG.md
Outdated
Show resolved
Hide resolved
# Conflicts: # packages/video_player/video_player/CHANGELOG.md # packages/video_player/video_player/lib/video_player.dart # packages/video_player/video_player/pubspec.yaml # packages/video_player/video_player_android/example/lib/mini_controller.dart # packages/video_player/video_player_avfoundation/CHANGELOG.md # packages/video_player/video_player_avfoundation/example/lib/mini_controller.dart # packages/video_player/video_player_avfoundation/lib/src/avfoundation_video_player.dart # packages/video_player/video_player_avfoundation/pubspec.yaml
…tsPictureInPicture
@tarrinneal I updated my pull request fully retested it to make sure it does what I expect. |
@@ -106,6 107,9 @@ class VideoPlayerValue { | |||
/// The current speed of the playback. | |||
final double playbackSpeed; | |||
|
|||
/// True if picture-in-picture is currently active. | |||
final bool isPictureInPictureActive; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vanlooverenkoen
Nice job, I'm in need of this feature.
I'm testing this pr in a project and I found a bug when updating this value. This property is not used in the bool operator ==(Object other)
function, so it is not updated in the ValueNotifier. Can you fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn! Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like you added a Dart unit test to cover that change (i.e., one which would have caught this bug).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like you added a Dart unit test to cover that change (i.e., one which would have caught this bug).
This doesn't appear to have been resolved.
Seems like you still have a few broken tests. I should be able to get this re-reviewed this week, if you can git them sorted out. |
@tarrinneal the tests are failing on camera because of the dependency overrides. How should I handle this? Because the dependency override script doesn't update it in the camera package. I will fix the merge conflicts today |
@stuartmorgan
|
@stuartmorgan what is the best way to fix check_podspecs & macos_platform_tests master? Just wrap everything related to pip with this?
|
That's correct. The
It depends on what you mean by "just wrap"; you'll need reasonable |
@@ -71,8 71,10 @@ - (FVPDisplayLink *)displayLinkWithRegistrar:(id<FlutterPluginRegistrar>)registr | |||
|
|||
#pragma mark - | |||
|
|||
@interface FVPVideoPlayer () | |||
API_AVAILABLE(macos(10.15)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuartmorgan is this how I should mark the FVPVideoPlayer? Or how else should I fix AVPictureInPicutreControllerDelegate
to only be available on macOS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is marking everything in the private interface as 10.15 ; you'll need to declare this in an extension:
API_AVAILABLE(macos(10.15))
@interface FVPVideoPlayer (AVPIPDelegate) <AVPictureInPictureControllerDelegate>
@end
@interface FVPVideoPlayer ()
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This will, correctly, cause you to need to adjust other guards later in the code, such as the pictureInPictureController
property and calls to it.)
@stuartmorgan I have fixed all bugs and failing CI checks |
@@ -30,3 30,14 @@ dev_dependencies: | |||
|
|||
flutter: | |||
uses-material-design: true | |||
|
|||
# FOR TESTING ONLY. DO NOT MERGE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the camera*
package overrides can be removed, since this won't affect the camera
usages.
If you want to enable picture-in-picture make sure to enable the `audio` capability (in Xcode's UI it will say **Audio, AirPlay, and Picture in Picture**). | ||
Not setting this capability but calling `setPictureInPictureOverlayRectMessage` and `setPictureInPicture` will not start the picture-in-picture. | ||
|
||
```xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There needs to be something in the text just before this that says exactly what file(s) this is showing.
VideoProgressIndicator(_controller, allowScrubbing: true), | ||
if (_controller.value.isPictureInPictureActive) ...<Widget>[ | ||
Container(color: Colors.white), | ||
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already the case.
@@ -106,6 107,9 @@ class VideoPlayerValue { | |||
/// The current speed of the playback. | |||
final double playbackSpeed; | |||
|
|||
/// True if picture-in-picture is currently active. | |||
final bool isPictureInPictureActive; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like you added a Dart unit test to cover that change (i.e., one which would have caught this bug).
This doesn't appear to have been resolved.
@@ -71,8 71,10 @@ - (FVPDisplayLink *)displayLinkWithRegistrar:(id<FlutterPluginRegistrar>)registr | |||
|
|||
#pragma mark - | |||
|
|||
@interface FVPVideoPlayer () | |||
API_AVAILABLE(macos(10.15)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is marking everything in the private interface as 10.15 ; you'll need to declare this in an extension:
API_AVAILABLE(macos(10.15))
@interface FVPVideoPlayer (AVPIPDelegate) <AVPictureInPictureControllerDelegate>
@end
@interface FVPVideoPlayer ()
...
@@ -84,6 86,7 @@ @interface FVPVideoPlayer () | |||
@property(nonatomic, readonly) BOOL isPlaying; | |||
@property(nonatomic) BOOL isLooping; | |||
@property(nonatomic, readonly) BOOL isInitialized; | |||
@property(nonatomic) BOOL isPictureInPictureStarted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No is
for the property, per https://google.github.io/styleguide/objcguide.html#objective-c-method-names
} | ||
} | ||
|
||
- (void)startOrStopPictureInPicture:(BOOL)shouldPictureInPictureStart { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems very confusing from an API standpoint that both
[self startOrStopPictureInPicture:foo];
(which is already hard to parse, since the bool argument isn't named by the signature in violation of standard Obj-C naming conventions)
and
self.isPictureInPictureStarted = foo;
exist, and do different things.
Why not just override the setter of the property to do what this method does, and eliminate this duplicate-sounding method?
@@ -664,6 664,30 @@ - (void)testSeekToleranceWhenSeekingToEnd { | |||
XCTAssertNil(error); | |||
XCTAssertEqual(avPlayer.volume, 0.1f); | |||
|
|||
// Set picture-in-picture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My earlier comment about this testing was never resolved.
@@ -31,6 32,34 @@ - (void)testPlayVideo { | |||
XCTAssertTrue([playButton waitForExistenceWithTimeout:30.0]); | |||
[playButton tap]; | |||
|
|||
if ([AVPictureInPictureController isPictureInPictureSupported]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a separate test.
bool isPictureInPictureSupported(); | ||
@ObjCSelector('setPictureInPictureOverlaySettings:') | ||
void setPictureInPictureOverlaySettings( | ||
SetPictureInPictureOverlaySettingsMessage msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New code should not use the message object pattern (and in fact the existing code has since been updated not to use it).
@vanlooverenkoen Are you still planning on updating this PR? |
@stuartmorgan Yes, for some reason I missed these comments again. Can we maybe plan a timeframe where I fix these comments and get a review right after, in order to prevent endless merge conflict fixes? Because everytime I come back to this PR it often takes more time to figure out what changed on main and if it affected my PR? Let me know if that is feasible, than I can add this PR again to my planning |
@vanlooverenkoen I should generally be able to turn around an incremental review for this PR within about a week going forward. In cases where there's a month or more between when I do a review and when the PR is updated again though, I need to re-review the entire large PR almost from scratch because I no longer have enough context to do an incremental review, and finding a large block of time to re-review everything can take longer. |
@stuartmorgan alright that is clear! Let me try to fit this in. Keep you posted |
Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. You must list at least one issue.
This feature is only available on iOS because android has a different implementation. simple_pip_mode can be used for Android
Fixes flutter/flutter#60048
Migration from flutter/plugin to flutter/packages is done with this pr
old pr: flutter/plugins#6284
No migration needed this is an addon
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.