-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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] Add optional web options #3259
[video_player] Add optional web options #3259
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@ditman @stuartmorgan The original PR was opened 3 months ago, would be nice to get some feedback on the api. I think this is a feature that can benefit flutter web users. |
Bringing over my API note from the other PR for convenience (/cc @ditman)
|
83a1037
to
7df5d41
Compare
@ditman Do you have an opinion on the API question above? |
Update from triage: waiting for @ditman's input on the high-level API question. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on the API, and small nitpicks in the PR in general.
I wonder if the new configuration object warrants being added to the videoPlayer
configuration, and instead expose the setWebOptions(WebOptions options)
method that users can call if needed!
(We've used other web strategies, but their usage is cumbersome to programmers, and I wouldn't recommend them until we flesh them out more!)
packages/video_player/video_player_web/lib/video_player_web.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_web/lib/src/video_player.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_web/lib/src/video_player.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_web/lib/src/video_player.dart
Outdated
Show resolved
Hide resolved
7df5d41
to
0d02f61
Compare
@ditman @stuartmorgan Thanks for the review. As more options may come in the future (i.e. mute, autoplay), I'd split the control options out to their own model I agree that |
@ditman Do you want to weigh in again on the structure we want for exposing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@defuncart I've been sold of the following: VideoPlayerWebOptions
is a stand-alone object, AND that it is contained within the VideoPlayerOptions
; that sounds good to me!
@ditman Do you want to weigh in again on the structure we want for exposing
The main question is whether we want to expose things through an options mechanism like this, or do something more direct like exposing the element for direct manipulation.
In the video_player
case, and because of how it uses a Controller object as a source of truth, I think @defuncart's solution is better than directly exposing the video
element to users.
Exposing the element directly would enable calls to play/pause/seek/change the volume
and the controller state would lose sync with the actual video playback element (at least until the controller fully reacts to events coming from the native video player object!).
@defuncart I think there's at least a couple of extra attributes that might be nice to have in this new configuration:
disablepictureinpicture
: Prevents the browser from suggesting a Picture-in-Picture context menu or to request Picture-in-Picture automatically in some cases.disableremoteplayback
: used to disable the capability of remote playback in devices that are attached using wired (HDMI, DVI, etc.) and wireless technologies (Miracast, Chromecast, DLNA, AirPlay, etc.).
They seem very related to "where you can display this video" (especially with the disabling of the contextMenu
).
Could you add them as well? That could also demonstrate the extensibility of the solution :)
packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart
Outdated
Show resolved
Hide resolved
packages/video_player/video_player_web/lib/src/video_player.dart
Outdated
Show resolved
Hide resolved
@ditman Added |
7f8d21b
to
e4655dc
Compare
I'm happy with the API @defuncart, thanks! The only unaddressed concern is using |
344ecd1
to
8c5b1f8
Compare
Platform Interface PR for Video Player Web Options (flutter/packages#3259).
Update from triage: the blocking PR is in the queue to land now. |
Web PR for Video Player Web Options (#3259).
4b31e18
to
b1ded59
Compare
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Only the changes to the core package are remaining now, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the bot has highlighted, now that this has been reduced to just the app-facing package it's surfaced that this is missing tests. We should have a test of the options being correctly passed through this layer.
This comment was marked as off-topic.
This comment was marked as off-topic.
@defuncart Are you still planning on updating this to add tests, per the comment above? |
@stuartmorgan @ditman What type of tests are expected here? How can |
b1ded59
to
15c2552
Compare
See my earlier comment. To put it another way: a test that would fail if the code you are adding in this PR were accidentally removed or broken by someone later.
You shouldn't need to mock it; we run Dart unit tests in both web and vm mode, so a test that is skipped on non-web will still run in CI. |
Thanks for the info, due to holidays, I won't be able to look into this for the next month. @wreppun if you'd like, feel free to take over adding the 🧪. |
I can only see 1 file change in this PR. Is this ready for review? |
Converting to a Draft; please feel free to mark this as ready for review once the tests have been added. |
any chance to merge this? This literally makes this lib unusable. |
@Thioby We cannot merge an uncompleted draft PR; anyone interested in accelerating the process of getting to a landable PR is welcome to contribute tests as discussed above. |
(triage): @defuncart Do you still have plans to come back to this PR and address the feedback given above? |
(triage): I am going to close this one since there hasn't been any follow-up. If you find the time to address the feedback given above please reopen this. Thank you. |
Assigning to myself to land this. Needs tests. |
Exports types `VideoPlayerWebOptions` and `VideoPlayerWebOptionsControls` to customize the `webOptions` field in `VideoPlayerOptions` objects. Forwards `webOptions` to the web implementation. ## Usage Can be used as follows: ```dart _controller = VideoPlayerController.asset( 'assets/Butterfly-209.mp4', videoPlayerOptions: const VideoPlayerOptions( webOptions: VideoPlayerWebOptions( controls: VideoPlayerWebOptionsControls.enabled( allowDownload: false, allowFullscreen: false, allowPlaybackRate: false, allowPictureInPicture: false, ), allowContextMenu: false, allowRemotePlayback: false, ), ), ); ``` <img width="967" alt="Bildschirmfoto 2023-07-06 um 17 04 59" src="https://github.com/flutter/packages/assets/13286425/0fa92713-11cb-4073-86cf-2ea4ba486a6c"> ## Issues * Fixes: flutter/flutter#150327 * Fixes: flutter/flutter#64397 * Fixes: flutter/flutter#62192 * Fixes part of: flutter/flutter#88151 * Lands: #3259 (adds missing test) Co-authored-by: James Leahy <[email protected]>
Can be used as follows:
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.