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

[video_player] Added setMaxVideoResolution to disambiguate over different video stream resolutions#6230

Closed
AngeloAvv wants to merge 17 commits intoflutter:mainfrom
AngeloAvv:video_player_resolution
Closed

[video_player] Added setMaxVideoResolution to disambiguate over different video stream resolutions#6230
AngeloAvv wants to merge 17 commits intoflutter:mainfrom
AngeloAvv:video_player_resolution

Conversation

@AngeloAvv
Copy link

@AngeloAvv AngeloAvv commented Aug 11, 2022

Since HLS streams can deliver multiple tracks with a single URL, it could be particularly useful to set a maximum video resolution to spare network bandwidth instead of picking the best stream that could also be calculated according to the device network speed.

The main issue:

Related issues:

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/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin 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.

AngeloAvv and others added 3 commits August 11, 2022 23:54
Fixed analysis for master channel
Fixed unit tests due do mismatching import
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.

Thanks for the contribution!

It looks like this only has tests that the new parameters are passed all the way through to the native code, but no tests that the native code actually does the correct things with them. We'll need test coverage of that in order to proceed with this PR, since that's the core of the functionality.

this.playbackSpeed = 1.0,
this.rotationCorrection = 0,
this.errorDescription,
this.maxVideoResolution,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually need this to be part of the state stream?

Copy link
Author

Choose a reason for hiding this comment

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

If I remove it, we should only rely on setMaxVideoResolution method to set the value. Plus, we won't be able to access to this information since we will need to remove it from the toString() method.

WDYT?

AngeloAvv and others added 2 commits August 16, 2022 19:24
# Conflicts:
#	packages/video_player/video_player_android/CHANGELOG.md
#	packages/video_player/video_player_android/pubspec.yaml
# Conflicts:
#	packages/video_player/video_player_android/CHANGELOG.md
#	packages/video_player/video_player_android/pubspec.yaml
# Conflicts:
#	packages/video_player/video_player/CHANGELOG.md
#	packages/video_player/video_player_android/CHANGELOG.md
#	packages/video_player/video_player_avfoundation/CHANGELOG.md
#	packages/video_player/video_player_platform_interface/CHANGELOG.md
@AngeloAvv
Copy link
Author

Hey @stuartmorgan, I added tests on both sides: Android and iOS native! Let me know if it's ok

@AngeloAvv AngeloAvv requested review from hellohuanlin and stuartmorgan-g and removed request for camsim99, ditman, gaaclarke and stuartmorgan-g August 18, 2022 15:11
# Conflicts:
#	packages/video_player/video_player/CHANGELOG.md
#	packages/video_player/video_player_android/CHANGELOG.md
#	packages/video_player/video_player_avfoundation/CHANGELOG.md
#	packages/video_player/video_player_platform_interface/CHANGELOG.md
#	packages/video_player/video_player_platform_interface/lib/messages.g.dart
#	packages/video_player/video_player_platform_interface/lib/method_channel_video_player.dart
#	packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
#	packages/video_player/video_player_platform_interface/pigeons/messages.dart
#	packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart
#	packages/video_player/video_player_platform_interface/test/test.dart
@AngeloAvv
Copy link
Author

Hey @stuartmorgan , do we have an ETA for this PR?

I need to understand if this feature will ever land in production.

@jmagman
Copy link
Member

jmagman commented Sep 7, 2022

cc @hellohuanlin

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.

The iOS part looks good. But android folks (maybe @camsim99?) may want to take a look as well.

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithTextureId:(NSNumber *)textureId
width:(NSNumber *)width
height:(NSNumber *)height;
Copy link
Contributor

Choose a reason for hiding this comment

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

it's recommended to do alloc/init explicitly instead of combining them.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is Pigeon-generated code; I filed a bug a while ago about it being non-idiomatic.

Copy link
Contributor

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

Left some comments on the Android side :)

path: ../
video_player_platform_interface: ">=4.2.0 <6.0.0"
video_player_platform_interface:
path: ../../video_player_platform_interface
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this just for testing?

Copy link
Author

Choose a reason for hiding this comment

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

Yes it is

sdk: flutter
video_player_platform_interface: ^5.1.1
video_player_platform_interface:
path: ../video_player_platform_interface
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for testing?

Copy link
Author

Choose a reason for hiding this comment

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

Yep

@github-actions github-actions bot added p: image_picker p: webview_flutter Edits files for a webview_flutter plugin labels Sep 11, 2022
AngeloAvv and others added 2 commits September 11, 2022 10:09
# Conflicts:
#	packages/webview_flutter/webview_flutter_android/test/webview_android_widget_test.mocks.dart
@GaryQian
Copy link
Contributor

@stuartmorgan Could you take a look at this to see if this API is reasonable?

@camsim99 camsim99 self-requested a review October 25, 2022 17:21
Copy link
Contributor

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

The Android part looks good to me! @stuartmorgan @bparrishMines can one of you take a look at the overall structure?

Comment on lines +91 to +92
/// Sets the max video resolution to a [resolution] value allowing the player
/// to reproduce lwoer resolution streams.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think the wording on this could be improved. Something like

Suggested change
/// Sets the max video resolution to a [resolution] value allowing the player
/// to reproduce lwoer resolution streams.
/// Sets the maximum allowed video resolution to [resolution], allowing the
/// player to produce streams below this resolution.

Comment on lines +116 to +117
/// The video resolution, the number of distinct pixels in each dimension that
/// can be displayed
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be improved as well:

Suggested change
/// The video resolution, the number of distinct pixels in each dimension that
/// can be displayed
/// The number of distinct pixels in each dimension that can be displayed for
/// a video.

# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 6.0.0
version: 6.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be bumped to 6.1.0 since it is adding a new feature.

// Setting the playback speed on iOS will trigger the video to play. We
// prevent this from happening by not applying the playback speed until
// the video is manually played from Flutter.
if (!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.

Is this check necessary for this method? It looks like it was copied from _applyPlaybackSpeed().

return;
}

// If we haven't set a max video resolution we won't do anything
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is setting a max video resolution ignored if one is not already set? The public method, setMaxVideoResolution, should also contain this information.

/// Sets the max video resolution of [this].
///
/// The [resolution] will be used to set a maximum resolution value which will
/// allow the player to pick a different stream to play
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
/// allow the player to pick a different stream to play
/// allow the player to pick a different stream to play.

repository: https://github.com/flutter/plugins/tree/main/packages/video_player/video_player
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.4.7
version: 2.4.8
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a major version bump since it is adding a feature. (e.g. 2.5.0). Although the exact value may change by the time the PR is ready to land.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

(Please, do revert changes to files that are not relevant to the PR; thanks!)

Comment on lines -25 to +26
class _FakeLostDataResponse_1 extends _i1.Fake
implements _i2.LostDataResponse {}
class _FakeLostDataResponse_1 extends _i1.Fake implements _i2.LostDataResponse {
}
Copy link
Member

Choose a reason for hiding this comment

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

Please, revert this file, this pr has nothing to do with the image_picker package.

Comment on lines -25 to +26
class _FakeDownloadListener_0 extends _i1.Fake
implements _i2.DownloadListener {}
class _FakeDownloadListener_0 extends _i1.Fake implements _i2.DownloadListener {
}
Copy link
Member

Choose a reason for hiding this comment

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

Please, revert this file, this pr has nothing to do with the webview_flutter package.

@stuartmorgan-g
Copy link
Contributor

@AngeloAvv Are you still planning on updating this based on the comments above?

1 similar comment
@reidbaker
Copy link
Contributor

@AngeloAvv Are you still planning on updating this based on the comments above?

@AngeloAvv
Copy link
Author

@stuartmorgan @reidbaker sure! I just need to find a spot in the next weeks to address the changes.

@stuartmorgan-g
Copy link
Contributor

We've just completed the migration of the plugin code to the flutter/packages repository, as described in https://flutter.dev/go/flutter-plugins-repo-migration, and this repository is now being archived. Unfortunately that means that all in-progress PRs here must be moved to flutter/packages.

Please see our instructions for an explanation of how to move your PR, and if you have any issues moving your PR please don't hesitate to reach out in the #hackers-ecosystem channel in Discord.

Our apologies that your PR was caught in this one-time transition. We're aware that it's disruptive in the short term, and appreciate your help in getting us to a better long-term state!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants