Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
595d3df
#60048: Migration from flutter-plugins to flutter-packages
vanlooverenkoen Mar 20, 2023
4831f57
Updated doc
vanlooverenkoen Mar 20, 2023
976b630
Merged current main into ios pip
vanlooverenkoen Mar 20, 2023
a7d5dd5
#60048: Formatting
vanlooverenkoen Mar 20, 2023
876dfe8
Fixed formatting
vanlooverenkoen Mar 20, 2023
a4ca9e7
#60048: Updated the changelogs
vanlooverenkoen Mar 21, 2023
49f769a
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 3, 2023
5477f0b
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 15, 2023
0764e27
#60048: Updated comments related to docs & typo's
vanlooverenkoen Apr 15, 2023
65fdf65
Renamed setAutomaticallyStartPictureInPicture to setAutomaticallyStar…
vanlooverenkoen Apr 16, 2023
d4d9ff9
Updated starting to started to match stopped enum values
vanlooverenkoen Apr 17, 2023
ff6d02f
Removed some logic to pause
vanlooverenkoen Apr 17, 2023
ae7500a
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen May 10, 2023
4eeb6e1
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen May 11, 2023
9110d0f
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Jun 22, 2023
211c6b3
Fixed the formatting & pigeon run
vanlooverenkoen Jun 22, 2023
5a8735b
Fixed documentation
vanlooverenkoen Jun 22, 2023
4583229
Updated the dto's to setup the picture in picture
vanlooverenkoen Jun 22, 2023
70284aa
Fixed documentation
vanlooverenkoen Jun 23, 2023
7289998
Fixed 2 bugs where the permissions were not correct and an issue with…
vanlooverenkoen Jun 23, 2023
ee96f77
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Jun 23, 2023
da13c09
Fixed formatting & tests
vanlooverenkoen Jun 23, 2023
4d83a52
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Jun 24, 2023
ac920fe
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Jul 25, 2023
8394840
Fixed the version bumper for the the video_player itself
vanlooverenkoen Jul 25, 2023
19b1440
Fixed comments
vanlooverenkoen Jul 25, 2023
1963d27
Fixed some comments
vanlooverenkoen Jul 31, 2023
f71a27a
Fixed formaating
vanlooverenkoen Jul 31, 2023
b3e05a0
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Jul 31, 2023
1325254
Fixed documentation
vanlooverenkoen Jul 31, 2023
72ba79a
Fixed comment on UIBackgroundModes
vanlooverenkoen Aug 1, 2023
8c67ab8
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Aug 1, 2023
f935a16
Fixed a bug where the top & left overlay settings were incorrect
vanlooverenkoen Aug 1, 2023
42a7815
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Nov 25, 2023
fa93319
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Nov 25, 2023
b0103d0
updated documentation
vanlooverenkoen Nov 25, 2023
236ab51
fix ios tests
vanlooverenkoen Nov 25, 2023
1cf961d
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Dec 14, 2023
5c18256
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Mar 7, 2024
ddc7139
camera override video_player plugin
vanlooverenkoen Mar 7, 2024
45494b9
fix camera dependency overrides
vanlooverenkoen Mar 7, 2024
0597f32
fix macos implementation (only do validation on capabilities on iOS &…
vanlooverenkoen Mar 7, 2024
5c1f759
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Mar 8, 2024
e94ccaa
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Mar 11, 2024
9dc85a0
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 23, 2024
2b72605
fix formatting
vanlooverenkoen Apr 23, 2024
601c506
fix formatting & unwanted changes
vanlooverenkoen Apr 23, 2024
4574fa9
fix: remove the video_player dependency overrides
vanlooverenkoen Apr 23, 2024
1135695
fix: add the dependency override of video_player_avfoundation
vanlooverenkoen Apr 23, 2024
cd7fede
fix: add all the correct dependency overrides
vanlooverenkoen Apr 23, 2024
e9aba08
changelog version to specific version
vanlooverenkoen Apr 23, 2024
30c0b7a
Update pubspec.yaml
vanlooverenkoen Apr 23, 2024
c0ccbfc
Update pubspec.yaml
vanlooverenkoen Apr 23, 2024
8ee1dcb
fix: formatting of video_player
vanlooverenkoen Apr 23, 2024
58db59a
fix: compatability
vanlooverenkoen Apr 23, 2024
16ae8cb
fix: integervalue
vanlooverenkoen Apr 23, 2024
a15c3b7
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 23, 2024
87b92c2
fix: test on macOS
vanlooverenkoen Apr 23, 2024
5183028
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 24, 2024
002faa0
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 25, 2024
148cd55
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 25, 2024
d88cf33
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 25, 2024
45f96f5
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen Apr 26, 2024
9459bd5
Merge branch 'main' into feature/#60048-ios-picture-in-picture
vanlooverenkoen May 8, 2024
d9f883b
fix formatting
vanlooverenkoen May 8, 2024
c9993dc
fix: macos checks
vanlooverenkoen May 8, 2024
3e401c1
fix: comment
vanlooverenkoen May 8, 2024
b250e9c
fix: check on macOS where there are no capabilities required to use p…
vanlooverenkoen May 8, 2024
01aaf8d
Revert "fix: add all the correct dependency overrides"
Nols1000 Jan 2, 2025
ee6db47
Revert "camera override video_player plugin"
Nols1000 Jan 2, 2025
2e3196b
Update the documentation on configuring the required ios capabilities
Nols1000 Jan 2, 2025
29c1d3b
Merge remote-tracking branch 'origin/main' into feature/#60048-ios-pi…
Nols1000 Jan 2, 2025
6d8fb1e
[video_player_android] regenerate pigeons
Nols1000 Jan 2, 2025
114f5b8
[video_player_avfoundation] regenerate pigeons
Nols1000 Jan 2, 2025
5861e1d
Revert changes to the camera_android_camerax example
Nols1000 Jan 2, 2025
114f9ac
[video_player] fix todo making the picture-in-picture message const
Nols1000 Jan 2, 2025
3c1b4e6
[video_player] add tests to ensure equals implementation for isPictur…
Nols1000 Jan 2, 2025
3985a77
[video_player_avfoundation] refactor picture in picture extension
Nols1000 Jan 3, 2025
1649be4
[video_player_avfoundation] refactor code
Nols1000 Jan 3, 2025
bc56139
[video_player] format code
Nols1000 Jan 3, 2025
e1348c8
[video_player_avfoundation] reorder imports
Nols1000 Jan 3, 2025
7e70da0
[video_player] update version
Nols1000 Jan 3, 2025
4abe6f1
[video_player_android] Revert all changes made to this package
Nols1000 Jan 3, 2025
2006494
[video_player] upgrade dependencies
Nols1000 Jan 3, 2025
58dabf4
[video_player] fix dependencies for example
Nols1000 Jan 3, 2025
881e80e
[video_player_android] add overwrite to fix analysis error
Nols1000 Jan 3, 2025
917bdd4
[video_player_avfoundation] fix type issue with isPictureInPictureSup…
Nols1000 Jan 4, 2025
fba55da
[video_player_avfoundation] refactore naming and setting the start of…
Nols1000 Jan 5, 2025
b0f42d8
[video_player] Update dependencies
Nols1000 Jan 8, 2025
e0231d8
Merge remote-tracking branch 'origin/main' into feature/#60048-ios-pi…
Nols1000 Jan 8, 2025
c58b722
[video_player] Upgrade dart version
Nols1000 Jan 8, 2025
376bcf5
[video_player] Update dependencies
Nols1000 Jan 8, 2025
5dd6e13
[camera] Add video_player_platform_interface to overwrite
Nols1000 Jan 8, 2025
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
Prev Previous commit
Next Next commit
#60048: Updated comments related to docs & typo's
  • Loading branch information
vanlooverenkoen committed Apr 15, 2023
commit 0764e27736618d224c9ee94baeb8d9e469b40556
2 changes: 1 addition & 1 deletion packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.7.0

* Added support for picture in picture on iOS
* Adds support for picture-in-picture on iOS.

## 2.6.1

Expand Down
14 changes: 7 additions & 7 deletions packages/video_player/video_player/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ and so on.

To learn about playback speed limitations, see the [`setPlaybackSpeed` method documentation](https://pub.dev/documentation/video_player/latest/video_player/VideoPlayerController/setPlaybackSpeed.html).

### Picture in Picture
### Picture-in-Picture

#### iOS
On iOS the picture in picture is linked to the AVPlayerController.
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.
On iOS the picture-in-picture is linked to the AVPlayerController.
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
<key>UIBackgroundModes</key>
Expand All @@ -150,14 +150,14 @@ Not setting this capability but calling `setPictureInPictureOverlayRectMessage`
```

Example:
![The example app running in iOS with picture in picture enabled](https://github.com/flutter/plugins/blob/main/packages/video_player/video_player/doc/demo_pip_iphone.gif?raw=true)
![The example app running in iOS with picture-in-picture enabled](https://github.com/flutter/plugins/blob/main/packages/video_player/video_player/doc/demo_pip_iphone.gif?raw=true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

READMEs should never have references to non-pinned URLs, as it means old versions' READMEs can change or break at any time. E.g., renaming the plugin in the future would break all previous READMEs.

This will need to be added in a follow-up PR, using a hash instead of main.


#### Android

On Android the implementation is different. There is no link to the video player. Your complete app will be minimized ([picture in picutre Android documentation](https://developer.android.com/guide/topics/ui/picture-in-picture))
On Android there is no link to the video player. Your complete app will be minimized ([picture-in-picture Android documentation](https://developer.android.com/guide/topics/ui/picture-in-picture))

You have multiple options on Android:
- [simple_pip_mode](https://pub.dev/packages/simple_pip_mode)
- Create your own plugin that follows the andorid documentation
- Create your own plugin that follows the android documentation

Furthermore, see the example app for an example playback speed implementation.
14 changes: 7 additions & 7 deletions packages/video_player/video_player/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
future: _controller.isPictureInPictureSupported(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't most of the UI need to be conditional on this? It looks like the button below to trigger PiP is unconditionally enabled and will call a method that isn't implemented on most platforms, for instance.

builder: (BuildContext context, AsyncSnapshot<bool> snapshot) =>
Text(snapshot.data ?? false
? 'Picture in picture is supported'
: 'Picture in picture is not supported'),
? 'Picture-in-picture is supported'
: 'Picture-in-picture is not supported'),
),
Row(
children: <Widget>[
const SizedBox(width: 16),
const Expanded(
child: Text(
'Start picture in picture automatically when going to background'),
'Start picture-in-picture automatically when going to background'),
),
Switch(
value: _enableStartPictureInPictureAutomaticallyFromInline,
Expand Down Expand Up @@ -296,7 +296,7 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
),
);
},
child: const Text('Set picture in picture overlay rect'),
child: const Text('Set picture-in-picture overlay rect'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this something that clients have to call manually? Shouldn't the controller be determining this information from the widget as needed?

),
MaterialButton(
color: Colors.blue,
Expand All @@ -308,8 +308,8 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
}
},
child: Text(_controller.value.isPictureInPictureActive
? 'Stop picture in picture'
: 'Start picture in picture'),
? 'Stop picture-in-picture'
: 'Start picture-in-picture'),
),
Container(
padding: const EdgeInsets.all(20),
Expand All @@ -330,7 +330,7 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
children: const <Widget>[
Icon(Icons.picture_in_picture),
SizedBox(height: 8),
Text('This video is playing in picture in picture.'),
Text('This video is playing in picture-in-picture.'),
],
),
] else ...<Widget>[
Expand Down
16 changes: 9 additions & 7 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class VideoPlayerValue {
/// The current speed of the playback.
final double playbackSpeed;

/// True if picture in picture is currently active.
/// True if picture-in-picture is currently active.
final bool isPictureInPictureActive;

/// A description of the error if present.
Expand Down Expand Up @@ -577,25 +577,27 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
await _videoPlayerPlatform.setVolume(_textureId, value.volume);
}

/// Returns true if picture in picture is supported on the device.
/// Returns true if picture-in-picture is supported on the device.
Future<bool> isPictureInPictureSupported() =>
_videoPlayerPlatform.isPictureInPictureSupported();

/// Enable/disable to start picture in picture automatically when the app goes to the background.
/// Enable/disable to start picture-in-picture automatically when the app goes to the background.
Future<void> setAutomaticallyStartPictureInPicture({
required bool enableStartPictureInPictureAutomaticallyFromInline,
}) async {
if (!value.isInitialized || _isDisposed) {
return;
}
await _videoPlayerPlatform.setAutomaticallyStartPictureInPicture(
await _videoPlayerPlatform.setAutomaticallyStartsPictureInPicture(
textureId: _textureId,
enableStartPictureInPictureAutomaticallyFromInline:
enableStartPictureInPictureAutomaticallyFromInline,
);
}

/// Set the location of the video player view. So picture in picture can use it for animating
/// Set the location of the video player view. So picture-in-picture can use it for animating.
/// The rect will represent the location of the video player view in Flutter. The rect will be
/// passed to the platform to position the native picture-in-picture overlay correctly.
Future<void> setPictureInPictureOverlayRect({
required Rect rect,
}) async {
Expand All @@ -608,15 +610,15 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
);
}

/// Start picture in picture mode
/// Start picture-in-picture mode.
Future<void> startPictureInPicture() async {
if (!value.isInitialized || _isDisposed) {
return;
}
await _videoPlayerPlatform.startPictureInPicture(_textureId);
}

/// Stop picture in picture mode
/// Stop picture-in-picture mode.
Future<void> stopPictureInPicture() async {
if (!value.isInitialized || _isDisposed) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.5.0

* Added support for picture in picture on iOS
* Adds support for picture-in-picture on iOS.

## 2.4.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ - (void)testTransformFix {
XCTAssertNil(error);
XCTAssertEqual(avPlayer.volume, 0.1f);

// Set Picture In Picture
// Set picture-in-picture
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why the existing test is written this way, but we should have one test method per logical test. So all of this should be in new test methods that each exercise specific parts of the new logic.

They should also fully cover it, which means at least one call to each method, and probably more (for branches).

NSNumber *isPictureInPictureSupported = [videoPlayerPlugin isPictureInPictureSupported:&error];
XCTAssertNil(error);
XCTAssertNotNil(isPictureInPictureSupported);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ - (void)testPlayVideo {
[playButton tap];

if ([AVPictureInPictureController isPictureInPictureSupported]) {
Copy link
Collaborator

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This still needs to be resolved.

XCUIElement *pipSupportedText = app.staticTexts[@"Picture in picture is supported"];
XCUIElement *pipSupportedText = app.staticTexts[@"Picture-in-picture is supported"];
XCTAssertTrue([pipSupportedText waitForExistenceWithTimeout:30.0]);

XCUIElement *pipPrepareButton = app.buttons[@"Set picture in picture overlay rect"];
XCUIElement *pipPrepareButton = app.buttons[@"Set picture-in-picture overlay rect"];
XCTAssertTrue([pipPrepareButton waitForExistenceWithTimeout:30.0]);
[pipPrepareButton tap];

XCUIElement *pipStartButton = app.buttons[@"Start picture in picture"];
XCUIElement *pipStartButton = app.buttons[@"Start picture-in-picture"];
XCTAssertTrue([pipStartButton waitForExistenceWithTimeout:30.0]);
[pipStartButton tap];

XCUIElement *pipUIView = app.otherElements[@"PIPUIView"];
XCTAssertTrue([pipUIView waitForExistenceWithTimeout:30.0]);

XCUIElement *pipStopButton = app.buttons[@"Stop picture in picture"];
XCUIElement *pipStopButton = app.buttons[@"Stop picture-in-picture"];
XCTAssertTrue([pipStopButton waitForExistenceWithTimeout:30.0]);
[pipStopButton tap];

Expand All @@ -57,7 +57,7 @@ - (void)testPlayVideo {
XCTAssertFalse([pipUIView exists]);
} else {
XCTAssertTrue(
[app.staticTexts[@"Picture in picture is not supported"] waitForExistenceWithTimeout:30.0]);
[app.staticTexts[@"Picture-in-picture is not supported"] waitForExistenceWithTimeout:30.0]);
}

NSPredicate *find1xButton = [NSPredicate predicateWithFormat:@"label CONTAINS '1.0x'"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
future: _controller.isPictureInPictureSupported(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) =>
Text(snapshot.data ?? false
? 'Picture in picture is supported'
: 'Picture in picture is not supported'),
? 'Picture-in-picture is supported'
: 'Picture-in-picture is not supported'),
),
Row(
children: <Widget>[
const SizedBox(width: 16),
const Expanded(
child: Text(
'Start picture in picture automatically when going to background'),
'Start picture-in-picture automatically when going to background'),
),
Switch(
value: _enableStartPictureInPictureAutomaticallyFromInline,
Expand Down Expand Up @@ -197,7 +197,7 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
),
);
},
child: const Text('Set picture in picture overlay rect'),
child: const Text('Set picture-in-picture overlay rect'),
),
MaterialButton(
color: Colors.blue,
Expand All @@ -209,8 +209,8 @@ class _BumbleBeeRemoteVideoState extends State<_BumbleBeeRemoteVideo> {
}
},
child: Text(_controller.value.isPictureInPictureActive
? 'Stop picture in picture'
: 'Start picture in picture'),
? 'Stop picture-in-picture'
: 'Start picture-in-picture'),
),
Container(
padding: const EdgeInsets.all(20),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class VideoPlayerValue {
/// The current speed of the playback.
final double playbackSpeed;

/// True if picture in picture is currently active.
/// True if picture-in-picture is currently active.
final bool isPictureInPictureActive;

/// A description of the error if present.
Expand Down Expand Up @@ -384,23 +384,23 @@ class MiniController extends ValueNotifier<VideoPlayerValue> {
await _applyPlaybackSpeed();
}

/// Returns true if picture in picture is supported on the device.
/// Returns true if picture-in-picture is supported on the device.
Future<bool> isPictureInPictureSupported() {
return _platform.isPictureInPictureSupported();
}

/// Enable/disable to start picture in picture automatically when the app goes to the background.
/// Enable/disable to start picture-in-picture automatically when the app goes to the background.
Future<void> setAutomaticallyStartPictureInPicture({
required bool enableStartPictureInPictureAutomaticallyFromInline,
}) {
return _platform.setAutomaticallyStartPictureInPicture(
return _platform.setAutomaticallyStartsPictureInPicture(
textureId: textureId,
enableStartPictureInPictureAutomaticallyFromInline:
enableStartPictureInPictureAutomaticallyFromInline,
);
}

/// Set the location of the video player view. So picture in picture can use it for animating
/// Set the location of the video player view. So picture-in-picture can use it for animating
Future<void> setPictureInPictureOverlayRect({
required Rect rect,
}) {
Expand All @@ -410,12 +410,12 @@ class MiniController extends ValueNotifier<VideoPlayerValue> {
);
}

/// Start picture in picture mode
/// Start picture-in-picture mode.
Future<void> startPictureInPicture() {
return _platform.startPictureInPicture(textureId);
}

/// Stop picture in picture mode
/// Stop picture-in-picture mode.
Future<void> stopPictureInPicture() {
return _platform.stopPictureInPicture(textureId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ @interface FLTVideoPlayer
// streams (not just iOS 16). (https://github.com/flutter/flutter/issues/109116).
// An invisible AVPlayerLayer is used to overwrite the protection of pixel buffers in those streams
// for issue #1, and restore the correct width and height for issue #2.
// It is also used to start picture in picture
// It is also used to start picture-in-picture
@property(readonly, nonatomic) AVPlayerLayer *playerLayer;
@property(readonly, nonatomic) CADisplayLink *displayLink;
@property(nonatomic) AVPictureInPictureController *pictureInPictureController;
Expand Down Expand Up @@ -258,10 +258,10 @@ - (instancetype)initWithPlayerItem:(AVPlayerItem *)item
// video streams (not just iOS 16). (https://github.com/flutter/flutter/issues/109116). An
// invisible AVPlayerLayer is used to overwrite the protection of pixel buffers in those streams
// for issue #1, and restore the correct width and height for issue #2.
// It is also used to start picture in picture
// It is also used to start picture-in-picture
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
// We set the opacity to 0.001 because it is an overlay.
// Picture in picture will show a placeholder over other widgets when video_player is used in a
// Picture-in-picture will show a placeholder over other widgets when video_player is used in a
// ScrollView, PageView or in a widget that changes location.
_playerLayer.opacity = 0.001;
Copy link
Contributor

Choose a reason for hiding this comment

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

why 0.001? The comment says "because it is an overlay." But why is it this number in that situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't understand, either from the code comment or the linked discussion, what exactly this is doing. Please add detail to the code comment clearly explaining what the issue being worked around here is. What would happen if we removed this line, or if we used 0 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The documentation is updated, can you check if this is better for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this overlay intercept taps and other gestures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it does not

[rootViewController().view.layer addSublayer:_playerLayer];
Expand Down Expand Up @@ -311,8 +311,7 @@ - (void)startOrStopPictureInPicture:(BOOL)shouldPictureInPictureStart {
if (self.pictureInPictureController && self.isPictureInPictureStarted &&
![self.pictureInPictureController isPictureInPictureActive]) {
if (_eventSink != nil) {
// The event is already send here to make sure that Flutter UI can be updates as soon as
// possible
// The event is sent here to make sure that the Flutter UI can be updated as soon as possible.
_eventSink(@{@"event" : @"startingPictureInPicture"});
}
[self.pictureInPictureController startPictureInPicture];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class AVFoundationVideoPlayer extends VideoPlayerPlatform {
}

@override
Future<void> setAutomaticallyStartPictureInPicture({
Future<void> setAutomaticallyStartsPictureInPicture({
required int textureId,
required bool enableStartPictureInPictureAutomaticallyFromInline,
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void main() {
});

test('setAutomaticallyStartPictureInPicture true', () async {
await player.setAutomaticallyStartPictureInPicture(
await player.setAutomaticallyStartsPictureInPicture(
textureId: 1,
enableStartPictureInPictureAutomaticallyFromInline: true);
expect(log.log.last, 'setAutomaticallyStartPictureInPicture');
Expand All @@ -289,7 +289,7 @@ void main() {
});

test('setAutomaticallyStartPictureInPicture false', () async {
await player.setAutomaticallyStartPictureInPicture(
await player.setAutomaticallyStartsPictureInPicture(
textureId: 1,
enableStartPictureInPictureAutomaticallyFromInline: false);
expect(log.log.last, 'setAutomaticallyStartPictureInPicture');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 6.2.0

* Added support for picture in picture on iOS
* Adds support for picture-in-picture on iOS.

## 6.1.0

Expand Down
Loading