-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[video_player] upgraded video_player to use pigeon #2544
Conversation
8c4c695 to
0f60ba4
Compare
0a689b7 to
e728df8
Compare
xster
left a comment
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.
Some notes but this is looking great!!
| public class Messages { | ||
|
|
||
| /** Generated class from Pigeon that represents data sent in messages. */ | ||
| public static class VoidMessage { |
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.
ya, supporting null would be great
| } | ||
|
|
||
| /** Generated class from Pigeon that represents data sent in messages. */ | ||
| public static class TextureMessage { |
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.
This is more of a comment for https://github.com/flutter/plugins/pull/2544/files#diff-eba6bc6c27f777f5309e5a219983ec11R34 but I'm here now. This seems like a good place to demonstrate "primitives" since the original implementation for java is just a long too. Could the IDL just be int create(CreateMessage msg);?
| public Long getTextureId() { return textureId; } | ||
| public void setTextureId(Long setterArg) { this.textureId = setterArg; } | ||
|
|
||
| HashMap toMap() { |
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.
Meta-context for the comment above, one of the struggles big apps tend to get into is once you unpack the APK, 1/3 of the APK size is from the proto generated outputs with a bunch of helper functions. I don't think we'll run into it any time soon but it's good to let primitives be primitives where possible.
| public static class CreateMessage { | ||
| private String asset; | ||
| public String getAsset() { return asset; } | ||
| public void setAsset(String setterArg) { this.asset = setterArg; } |
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 think the java part wasn't in the original doc but looking at this again, could we default to immutables only (fields can only be set via constructor (fromMap in this case) unless specifically annotated?
| public String getFormatHint() { return formatHint; } | ||
| public void setFormatHint(String setterArg) { this.formatHint = setterArg; } | ||
|
|
||
| HashMap toMap() { |
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'm thinking, since the APIs are directional in the IDL, this should theoretically never be needed right? Could we omit this by default unless we annotate it somehow?
| VoidMessage pause(TextureMessage msg); | ||
| } | ||
|
|
||
| void setupPigeon(PigeonOptions opts) { |
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.
So in this whole file, only the import line and this function are required, everything else is freeform right? I wish we can somehow make this distinction clearer. Maybe we need a pub run to generate the dart template and this is pre-filled with a big dartdoc saying you need to fill this.
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.
This function isn't required. All of these flags can be supplied at command-line. I added this function so people can save arguments.
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.
right, understood.
1- I just meant how can we provide a clearer affordance to this thing? Maybe just a doc in the readme is ok. But since we're telling people to create this file from scratch, it would be good to have some template available.
2- kinda unrelated, can we tweak the name to not have setup in there? The generated java/objc code has the word setup in the static functions too and they mean pretty different things than this setup. Could be confusing if people cognitively mixed those things. Maybe just configurePigeon or some such.
| video_player_platform_interface: ^1.0.1 | ||
| video_player_platform_interface: | ||
| path: ../video_player_platform_interface | ||
| # The design on https://flutter.dev/go/federated-plugins was to leave |
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.
your change invalidates this comment right?
| sdk: flutter | ||
| pedantic: ^1.8.0 | ||
| pigeon: | ||
| path: ../../../../packages/packages/pigeon |
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.
We can probably just reference a version here right? If we were to actually check it in.
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'll change that when i switch from being a draft.
| } else { | ||
| return VoidMessage._fromMap(replyMap['result']); | ||
| } | ||
|
|
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.
nit: some whitespace unbalance here
| class VideoPlayerApi { | ||
| Future<VoidMessage> initialize(VoidMessage arg) async { | ||
| Map requestMap = arg._toMap(); | ||
| BasicMessageChannel channel = |
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 guess this part is a bit different from the receiving side. I get the ergonomics of it but I wonder what's the cost (if a function is invoked on each frame). Is it reasonable to save it somewhere?
|
@xster the Android and iOS example apps both work now, yay. |
fc5eddf to
d79ff02
Compare
99e6b0b to
ed4b42b
Compare
xster
left a comment
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.
LGTM
| return asset; | ||
| } | ||
|
|
||
| public void setAsset(String setterArg) { |
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.
forgot if we talked about this before. Perhaps for a v1.1. Can't all these be construction arguments rather than setters? Since the "receiver" can theoretically take this object as is and just pass it around deeper into their application as immutable data. It's harder to do if it's mutable.
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.
Good idea I've considered it i n the past, just haven't had the time: flutter/flutter#56496
Since java doesn't have named parameters i've never prioritized it to keep the generated code similar across platforms.
| @@ -0,0 +1,50 @@ | |||
| import 'package:pigeon/pigeon_lib.dart'; | |||
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.
nit, the convention is to have the main dart file be the same name as the package, e.g. package:pigeon/pigeon.dart
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.
| FLTVideoPlayerPlugin* instance = [[FLTVideoPlayerPlugin alloc] initWithRegistrar:registrar]; | ||
| [registrar addMethodCallDelegate:instance channel:channel]; | ||
| [registrar publish:instance]; | ||
| FLTVideoPlayerApiSetup(registrar.messenger, instance); |
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 wonder if we can make the requirement of calling this function more explicit.
What is the current failure message if the user didn't call this before using the pigeon generated code?
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.
It's the same error then if someone sent a message to a channel that hasn't had a callback set for it. It doesn't say anything specifically about Pigeon. Thats good feedback. I'll look into that for future versions.
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.
Sure. I guess documentations on the method would also help in some patch release.
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.
| + (FLTTextureMessage *)fromMap:(NSDictionary *)dict { | ||
| FLTTextureMessage *result = [[FLTTextureMessage alloc] init]; | ||
| result.textureId = dict[@"textureId"]; | ||
| if ((NSNull *)result.textureId == [NSNull null]) { |
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.
nits:
use if (![result.textureId iSKindOfClass:[NSNumber class]])
would also check the the type.
Or if we want to be more explicit about plugin passing the wrong type, we can add
if (![result.textureId iSKindOfClass:[NSNumber class]]) {
throw...
}
| } | ||
| - (NSDictionary *)toMap { | ||
| return | ||
| [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), |
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.
nits: I personally prefer
@{
@"textureId" : self.textureId ? self.textureId : [NSNull null])
};
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.
Good call. I would update this but since it is part of the generated code it is really an issue with pigeon, not this PR. That requires republishing pigeon, since it's a nit I'll address it later if you don't mind.
| description: Flutter plugin for displaying inline video with other Flutter | ||
| widgets on Android and iOS. | ||
| version: 0.10.9+1 | ||
| version: 0.10.10 |
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.
Does this PR change the public api of the plugin?
We usually only update minors when there are non-breaking public api changes.
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.
It doesn't change the API. It isn't a breaking change in that sense. It adds no new functionality from the users perspective.
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.
if it doesn't add anything from users perspective, we should change it to 0.10.9+2 so users
who depends on video_player: ^0.10.9^ can get this update.
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.
My understanding is that the "+N" nomenclature is for changes that don't change the binary. This doesn't change the intention of the code, but the binary is definitely changed.
cyanglaz
left a comment
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.
LGTM
a29a04b to
d3ce457
Compare
5722e2a to
4d3751d
Compare
32f5b25 to
dab2092
Compare
dab2092 to
d431937
Compare
|
Landing on red, the only breaking CI is submit-queue, this should fix it. @cyanglaz I had to make a few changes after your LGTM, but they were all fixing tests in case you want to review them. |
* master: (96 commits) Update README.md (flutter#2768) [url_launcher_web] Launch mailto urls in same window in Safari (flutter#2740) update README with enableJavaScript info (flutter#2766) Run publish ci check on master (flutter#2764) [image_picker] Add documentation for Android external storage permissions (flutter#2765) [package_info] add support for macos to package_info plugin (flutter#2618) fixed detach from engine logic (flutter#2759) [url_launcher] Initialize previousAutomaticSystemUiAdjustment in launch (flutter#2757) [google_maps_flutter] add todo on skipped test. (flutter#2752) [google_maps_flutter] use `WaitUntilTouchesEndedPolicy` to fix the cameraIdle not called issue on iOS (flutter#2746) Use Xvfb for Linux desktop tests (flutter#2750) update lower dart bound to 2.1.0 (flutter#2751) [camera] Update lower bound of dart dependency to 2.1.0. (flutter#2749) [battery] update dart deps lower bound to 2.1.0 (flutter#2748) [android_alarm_manager] update dart deps lower bound to 2.1.0 (flutter#2747) [url_launcher] Add web to example app. (flutter#2736) [in_app_purchase] update docs to warn about `completePurchase` (flutter#2739) [video_player] upgraded video_player to use pigeon (flutter#2544) [video_player]: fixed platform_interface unit tests (flutter#2745) [video_player]: added test class to fix video_player unit tests (flutter#2744) ... # Conflicts: # packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m
Description
Upgraded to use pigeon, parent commit: #2617
Related Issues
Related: flutter/flutter#32930
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?