Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@ghost
Copy link

@ghost ghost commented Mar 7, 2022

This PR picks up and continues #4908 to support background play

Fixes flutter/flutter#63836

- Add _ambiguate to address an analyzer error
- Increase the required version for video_player_platform_interface
  to 5.1.0, the first version where allowBackgroundPlayback appears
@stuartmorgan-g stuartmorgan-g changed the title Background play [video_player] Add new option for allowBackgroundPlayback Mar 7, 2022
- always_specify_types
- avoid_bool_literal_in_conditional_expressions
- avoid_function_literal_in_foreach_calls
- terminating new line
video_player_android: ^2.2.17
video_player_avfoundation: ^2.2.17
video_player_platform_interface: ">=4.2.0 <6.0.0"
video_player_platform_interface: ">=5.1.0 <6.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This should just be ^5.1.0. The other syntax was specifically to allow two major versions of the platform interface for a while.

Copy link
Author

Choose a reason for hiding this comment

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

Ah yes, of course. Done.

}

void main() {
void verifyPlayingWhenAppLifecyclePaused(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This should be private (_ verifyPlayingWhenAppLifecyclePaused)

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}

void main() {
void verifyPlayingWhenAppLifecyclePaused(
Copy link
Contributor

Choose a reason for hiding this comment

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

The name here seems confusing. How about _verifyPlayStateRespondsToLifecycle?

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good to me. Done.

void main() {
void verifyPlayingWhenAppLifecyclePaused(
VideoPlayerController controller, {
required bool isObserving,
Copy link
Contributor

Choose a reason for hiding this comment

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

s/isObsvering/shouldPauseInBackground/ to make what is being validated (rather than the implementation details of how that is achieved) clearer.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, sure thing. Done.

VideoPlayerController controller, {
required bool isObserving,
}) {
final bool wasPlayingBeforePause = controller.value.isPlaying;
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 make sense for a test to call this method when it's not playing already, so I would eliminate this and just start with expect(controller.value.isPlaying, true); as a starting condition. That should make the method easier to understand.

Copy link
Author

Choose a reason for hiding this comment

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

Good idea! Thanks. Done.

@stuartmorgan-g stuartmorgan-g requested a review from gaaclarke March 8, 2022 16:31
@stuartmorgan-g
Copy link
Contributor

@gaaclarke for second review

@ghost
Copy link
Author

ghost commented Mar 8, 2022

Thanks for the the review @stuartmorgan!

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

I made one minor formatting tweak to pubspec.yaml; LGTM with that.

@stuartmorgan-g
Copy link
Contributor

You'll need to merge master in again; there was an authentication change for Firebase Test Lab that required a commit, which is why this last CI run failed.

expect(controller.videoPlayerOptions!.mixWithOthers, true);
});

for (final bool allowBackgroundPlayback in <bool>[true, false]) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: instead of looping and asserting 2 different things, this should be 2 different independent tests (factor out shared code if needed). It's much easier to grok tests that are asserting absolutes instead of having the extra layer of indirection.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, fair point. Done.

@stuartmorgan-g stuartmorgan-g added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Mar 8, 2022
@fluttergithubbot fluttergithubbot merged commit b6dea96 into flutter:main Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

p: video_player waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[video_player] Keep audio playing in background

5 participants