Skip to content

Move Player.Listener impl, remove @VisibleForTesting isInitialized. - #6922

Merged
auto-submit[bot] merged 6 commits into
mainfrom
video-player-is-initialized-refactor
Jun 13, 2024
Merged

Move Player.Listener impl, remove @VisibleForTesting isInitialized.#6922
auto-submit[bot] merged 6 commits into
mainfrom
video-player-is-initialized-refactor

Conversation

@matanlurey

Copy link
Copy Markdown
Contributor

Similar to #6908, as part of flutter/flutter#148417.

I'm working on re-landing #6456, this time without using the ActivityAware interface (see flutter/flutter#148417). As part of that work, I'll need to better control the ExoPlayer lifecycle and save/restore internal state.

In this PR, I've removed the concept of the class being "initialized" or not - the only thing "initialized" means is "for a given instance of ExoPlayer, has received the 'initialized' event. As a result I removed the quasi-public API that was used for testing only and replaced it with observing what the real production instance does (Player.STATE_READY).

After this PR, I'll likely do one more pass around the constructors - the constructor that takes an ExoPlayer that is marked @VisibleForTestingalso doesn't make sense once we'll support suspending/resuming video players, so it will need to get reworked (probably into taking a factory method).

@matanlurey
matanlurey requested a review from gmackallJune 13, 2024 20:47
@matanlureymatanlurey changed the title Move listener class, remove visibleForTesting isInitialized.Move Player.Listener impl, remove @VisibleForTesting isInitialized.Jun 13, 2024
@matanlureymatanlurey added the override: no versioning needed Override the check requiring version bumps for most changes label Jun 13, 2024

@gmackallgmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly LGTM just one question about the Player.STATE_BUFFERING case

public void onPlaybackStateChanged(final int playbackState) {
switch (playbackState) {
case Player.STATE_BUFFERING:
setBuffering(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a slight behavior change, right?

Before we would always invoke videoPlayerEvents.onBufferingUpdate(exoPlayer.getBufferedPosition()):

setBuffering(true);
sendBufferingUpdate();

but now we only invoke it if we pass the check at the start of the slightly modified setBuffering.

I don't know enough about video_player to know if that case (we are in the case of this switch Player.STATE_BUFFERING while isBuffering is already true) can happen/matters, so feel free to ignore if it isn't important.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Not only was this a good catch, but you caught a bug missed in the previous refactor.

I've fixed this and added a test to catch regressions.

@matanlurey
matanlurey requested a review from gmackallJune 13, 2024 22:37
@matanlureymatanlurey added the override: no changelog needed Override the check requiring CHANGELOG updates for most changes label Jun 13, 2024
@matanlurey

Copy link
Copy Markdown
ContributorAuthor

@camsim99 I am going to add auto-submit to fix the previous regression, but please leave comments still and I promise I'll address in a follow-up PR.

@matanlureymatanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 13, 2024
@auto-submit

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/packages/6922, due to - The status or check suite Linux_android android_device_tests_shard_1 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submitauto-submitBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 13, 2024
@matanlureymatanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 13, 2024
@auto-submit
auto-submitBot merged commit dd04ab1 into mainJun 13, 2024
@auto-submit
auto-submitBot deleted the video-player-is-initialized-refactor branch June 13, 2024 23:42
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 14, 2024
auto-submitBot pushed a commit to flutter/flutter that referenced this pull request Jun 14, 2024
flutter/packages@7805455...dd04ab1
2024-06-13 matanlurey@users.noreply.github.com Move `Player.Listener` impl, remove `@VisibleForTesting isInitialized`. (flutter/packages#6922)
2024-06-13 engine-flutter-autoroll@skia.org Roll Flutter from b1f9d71 to 01db23b (15 revisions) (flutter/packages#6921)
2024-06-13 matanlurey@users.noreply.github.com Refactor `VideoPlayer` to be less exposed to `EventChannel` & related (flutter/packages#6908)
2024-06-13 v.ditsyak@gmail.com [go_router] Added proper `redirect` handling for `ShellRoute.$route` and `StatefulShellRoute.$route` for proper redirection handling in case of code generation (flutter/packages#6841)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jun 14, 2024
flutter/packages@7805455...dd04ab1
2024-06-13 matanlurey@users.noreply.github.com Move `Player.Listener` impl, remove `@VisibleForTesting isInitialized`. (flutter/packages#6922)
2024-06-13 engine-flutter-autoroll@skia.org Roll Flutter from b1f9d71 to 01db23b (15 revisions) (flutter/packages#6921)
2024-06-13 matanlurey@users.noreply.github.com Refactor `VideoPlayer` to be less exposed to `EventChannel` & related (flutter/packages#6908)
2024-06-13 v.ditsyak@gmail.com [go_router] Added proper `redirect` handling for `ShellRoute.$route` and `StatefulShellRoute.$route` for proper redirection handling in case of code generation (flutter/packages#6841)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jun 14, 2024
flutter/packages@7805455...dd04ab1
2024-06-13 matanlurey@users.noreply.github.com Move `Player.Listener` impl, remove `@VisibleForTesting isInitialized`. (flutter/packages#6922)
2024-06-13 engine-flutter-autoroll@skia.org Roll Flutter from b1f9d71 to 01db23b (15 revisions) (flutter/packages#6921)
2024-06-13 matanlurey@users.noreply.github.com Refactor `VideoPlayer` to be less exposed to `EventChannel` & related (flutter/packages#6908)
2024-06-13 v.ditsyak@gmail.com [go_router] Added proper `redirect` handling for `ShellRoute.$route` and `StatefulShellRoute.$route` for proper redirection handling in case of code generation (flutter/packages#6841)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose
To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622
Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
matanlurey added a commit that referenced this pull request Jun 25, 2024
…allback`. (#6982)
I'm working on re-landing #6456,
this time without using the `ActivityAware` interface (see
flutter/flutter#148417). As part of that work,
I'll need to better control the `ExoPlayer` lifecycle and save/restore
internal state.
Follows the patterns of some of the previous PRs, i.e.
- #6922
- #6908
The changes in this PR are _mostly_ tests, it was extremely difficult to
just add more tests to the already very leaky `VideoPlayer` abstraction
which had lots of `@VisibleForTesting` methods and other "holes" to
observe state. This PR removes all of that, and adds test coverage where
it was missing.
Namely it:
- Adds a new class, `VideoAsset`, that builds and configures the media
that `ExoPlayer` uses.
- Removes all "testing" state from `VidePlayer`, keeping it nearly
immutable.
- Added tests for most of the classes I've added since, which were
mostly missing.
That being said, this is a large change. I'm happy to sit down with
either of you and walk through it.
---
Opening as a draft for the moment, since there is a pubspec change
needing I want to handle first.
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…`. (flutter#6922)
Similar to flutter#6908, as part of flutter/flutter#148417.
I'm working on re-landing flutter#6456, this time without using the `ActivityAware` interface (see flutter/flutter#148417). As part of that work, I'll need to better control the `ExoPlayer` lifecycle and save/restore internal state.
In this PR, I've removed the concept of the class being "initialized" or not - the only thing "initialized" means is "for a given instance of `ExoPlayer`, has received the `'initialized'` event. As a result I removed the quasi-public API that was used for testing only and replaced it with observing what the real production instance does (`Player.STATE_READY`).
After this PR, I'll likely do one more pass around the constructors - the constructor that takes an `ExoPlayer` that is marked `@VisibleForTesting` _also_ doesn't make sense once we'll support suspending/resuming video players, so it will need to get reworked (probably into taking a factory method).
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…allback`. (flutter#6982)
I'm working on re-landing flutter#6456,
this time without using the `ActivityAware` interface (see
flutter/flutter#148417). As part of that work,
I'll need to better control the `ExoPlayer` lifecycle and save/restore
internal state.
Follows the patterns of some of the previous PRs, i.e.
- flutter#6922
- flutter#6908
The changes in this PR are _mostly_ tests, it was extremely difficult to
just add more tests to the already very leaky `VideoPlayer` abstraction
which had lots of `@VisibleForTesting` methods and other "holes" to
observe state. This PR removes all of that, and adds test coverage where
it was missing.
Namely it:
- Adds a new class, `VideoAsset`, that builds and configures the media
that `ExoPlayer` uses.
- Removes all "testing" state from `VidePlayer`, keeping it nearly
immutable.
- Added tests for most of the classes I've added since, which were
mostly missing.
That being said, this is a large change. I'm happy to sit down with
either of you and walk through it.
---
Opening as a draft for the moment, since there is a pubspec change
needing I want to handle first.
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
…`. (flutter#6922)
Similar to flutter#6908, as part of flutter/flutter#148417.
I'm working on re-landing flutter#6456, this time without using the `ActivityAware` interface (see flutter/flutter#148417). As part of that work, I'll need to better control the `ExoPlayer` lifecycle and save/restore internal state.
In this PR, I've removed the concept of the class being "initialized" or not - the only thing "initialized" means is "for a given instance of `ExoPlayer`, has received the `'initialized'` event. As a result I removed the quasi-public API that was used for testing only and replaced it with observing what the real production instance does (`Player.STATE_READY`).
After this PR, I'll likely do one more pass around the constructors - the constructor that takes an `ExoPlayer` that is marked `@VisibleForTesting` _also_ doesn't make sense once we'll support suspending/resuming video players, so it will need to get reworked (probably into taking a factory method).
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
…allback`. (flutter#6982)
I'm working on re-landing flutter#6456,
this time without using the `ActivityAware` interface (see
flutter/flutter#148417). As part of that work,
I'll need to better control the `ExoPlayer` lifecycle and save/restore
internal state.
Follows the patterns of some of the previous PRs, i.e.
- flutter#6922
- flutter#6908
The changes in this PR are _mostly_ tests, it was extremely difficult to
just add more tests to the already very leaky `VideoPlayer` abstraction
which had lots of `@VisibleForTesting` methods and other "holes" to
observe state. This PR removes all of that, and adds test coverage where
it was missing.
Namely it:
- Adds a new class, `VideoAsset`, that builds and configures the media
that `ExoPlayer` uses.
- Removes all "testing" state from `VidePlayer`, keeping it nearly
immutable.
- Added tests for most of the classes I've added since, which were
mostly missing.
That being said, this is a large change. I'm happy to sit down with
either of you and walk through it.
---
Opening as a draft for the moment, since there is a pubspec change
needing I want to handle first.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmitMerge PR when tree becomes green via auto submit Appoverride: no changelog neededOverride the check requiring CHANGELOG updates for most changesoverride: no versioning neededOverride the check requiring version bumps for most changesp: video_playerplatform-android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@matanlurey@gmackall