Skip to content
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

Open
wants to merge 86 commits into
base: main
Choose a base branch
from

Conversation

vanlooverenkoen
Copy link
Contributor

@vanlooverenkoen vanlooverenkoen commented Mar 20, 2023

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

demo_pip_iphone

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@vanlooverenkoen
Copy link
Contributor Author

@hellohuanlin & @stuartmorgan I did the migration from flutter/plugins#6284 to here

Copy link
Contributor

@hellohuanlin hellohuanlin left a 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

@camsim99 camsim99 removed their request for review March 27, 2023 15:33
@vanlooverenkoen
Copy link
Contributor Author

@tarrinneal can I assist you with the review?

Copy link
Contributor

@tarrinneal tarrinneal left a 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!

# 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
@vanlooverenkoen
Copy link
Contributor Author

@tarrinneal I updated my pull request fully retested it to make sure it does what I expect.

@tarrinneal tarrinneal requested a review from stuartmorgan April 17, 2023 18:44
@reidbaker reidbaker requested a review from camsim99 May 4, 2023 18:44
@@ -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;

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Damn! Good catch!

Copy link
Contributor

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).

Copy link
Contributor

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.

@tarrinneal
Copy link
Contributor

@tarrinneal I updated my pull request fully retested it to make sure it does what I expect.

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.

@vanlooverenkoen
Copy link
Contributor Author

@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
Copy link
Contributor

@Azzeccagarbugli
Copy link

Azzeccagarbugli commented Nov 28, 2024

Hello @vanlooverenkoen, I'm trying your branch to use the PiP mode with the video_player package in this way:

video_player:
      git: 
        url: https://github.com/vanlooverenkoen/flutter-packages.git
        path: packages/video_player/video_player
        ref: "feature/#60048-ios-picture-in-picture"

After doing a whole flutter clean and flutter pub cache repair, I still get the following error:

Error (Xcode): ../../.pub-cache/git/flutter-packages-b250e9c7c8cc79bb4a4d82e597d92e01e50f2c95/packages/video_player/video_player/lib/video_player.dart:635:14: Error: Type 'PictureInPictureOverlaySettings' not found.

Could not build the application for the simulator.
Error launching application on iPhone 16 Pro.
Flutter doctor [✓] Flutter (Channel stable, 3.24.5, on macOS 15.1.1 24B91 darwin-arm64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 16.1) [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Android Studio (version 2024.2) [✓] VS Code (version 1.95.3) [✓] Connected device (3 available) [✓] Network resources

! Doctor found issues in 1 category.

Do you know how I could fix this?

Thanks a lot in advance ✨


I got the package to work by overide the depency in the depency_overrides section in the pubspec.yaml, like this:

dependency_overrides:
  video_player_android:
    git: 
      url: https://github.com/vanlooverenkoen/flutter-packages.git
      path: packages/video_player/video_player_android
      ref: "feature/#60048-ios-picture-in-picture"
  video_player_avfoundation:
    git: 
      url: https://github.com/vanlooverenkoen/flutter-packages.git
      path: packages/video_player/video_player_avfoundation
      ref: "feature/#60048-ios-picture-in-picture"
  video_player_platform_interface:
    git: 
      url: https://github.com/vanlooverenkoen/flutter-packages.git
      path: packages/video_player/video_player_platform_interface
      ref: "feature/#60048-ios-picture-in-picture"  

And in the dependecy section I used this:

video_player:
      git: 
        url: https://github.com/vanlooverenkoen/flutter-packages.git
        path: packages/video_player/video_player
        ref: "feature/#60048-ios-picture-in-picture"

For now this is the only good workround that I found to solve the PiP issue 🫡

@kalismeras61
Copy link

@vanlooverenkoen do you have a plan update this PR with latest videoplayer changes?

@Nols1000
Copy link

Nols1000 commented Jan 3, 2025

Hi @vanlooverenkoen and @stuartmorgan, I've picked up the old branch and merged all changes from main. I've also done some refactoring and regenerating the pigeon files.
Most tests are passing except the test, that checks the "is supported" functionality. It seems that pigeon tries to cast the int into a bool? but fails (very similar to flutter/flutter#90512).
I've also not changed the setUpPictureInPictureController yet. I'm a bit confused on what the todo is there.
You all can check out my branch at Nols1000/packages feature/#60048-ios-picture-in-picture.
How would you like to proceed? Do we want to open a new PR? Can I open a PR to your branch @vanlooverenkoen?

Thanks for all the hard work and kindest regards,
Nils

@vanlooverenkoen
Copy link
Contributor Author

vanlooverenkoen commented Jan 3, 2025

Thanks @Nols1000!!!

It has been quite a hectic year for me! I don't have an active project where I use the video_player package which makes it even harder to stay on top of this pull request.

So thanks @Nols1000 for updating & fixing the merge conflicts. I have some fixes on my branch I did a couple weeks ago (not tested & not committed), but new merge conflicts are already added again.

@stuartmorgan I really want to get this merged, but what do you think is the best way forward?

I calculated all the hours I have spend on this PR and it is already 41,5hours sinds august 2022. So it would be ashame if all that time was for nothing. So thanks again @Nols1000 🙏

@Nols1000 Nols1000 requested a review from matanlurey as a code owner January 3, 2025 11:22
@github-actions github-actions bot removed the p: camera label Jan 3, 2025
@Nols1000
Copy link

Nols1000 commented Jan 3, 2025

Hi @vanlooverenkoen,
Thanks for reaching out. I've pushed the changes to you branch.

@stuartmorgan
Copy link
Contributor

@stuartmorgan I really want to get this merged, but what do you think is the best way forward?

Either one is fine; usually when people pick up unfinished PRs they aren't able to push to them so make a new PR, but since that's not an issue here continuing with the same PR shouldn't have any issues.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

A couple of quick notes on the updated version until I have time for a full review.

#import "./include/video_player_avfoundation/AVAssetTrackUtils.h"
#import "AVAssetTrackUtils.h"
#import "FVPDisplayLink.h"
#import "messages.g.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Local imports need to use project-relative paths; fixing that should fix the build_all CI failures.

@@ -4,10 +4,14 @@

#import "./include/video_player_avfoundation/FVPVideoPlayer.h"
#import "./include/video_player_avfoundation/FVPVideoPlayer_Test.h"
#import "./include/video_player_avfoundation/AVAssetTrackUtils.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is incorrect; please see the style guide rules for header import ordering.

@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.5.0), do not edit directly.
// Autogenerated from Pigeon (v22.7.2), do not edit directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was video_player_android Pigeon code regenerated for this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ios][video_player] pip - picture in picture