-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Adding Video Capability to image_picker #565
Conversation
Don't do reentrant message channel calls. (#560)
- Tested on Google Pixel - Tested on iPhone X
|
Ready for Review. |
mravn-google
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.
Thank you very much for your contribution! Sorry for the review latency.
| assert(source != null); | ||
|
|
||
| if (maxWidth != null && maxWidth < 0) { | ||
| throw new ArgumentError.value(maxWidth, 'maxWidth can\'t be negative'); |
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.
Please use "cannot" rather than "can't".
| 'maxHeight': maxHeight, | ||
| }, | ||
| ); | ||
| return path != null ? new File(path) : 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.
[nit] Inverting the condition avoids the negation:
return path == null ? null : new File(path);| NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; | ||
| if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { | ||
| _result(tmpPath); | ||
| if (videoURL != nil) { |
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.
Could we avoid working on the image above, if videoURL is not nil? Seems to be wasted effort.
| ]; | ||
| _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; | ||
|
|
||
| _result = 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.
The code from here and until line 102 appears to be a copy of the image case. Could we refactor to avoid the duplication?
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.
Would a shared function containing the shared code be better for this? I duplicated it so I could provide different errors in the 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.
I'll leave it up to you.
| @@ -1,11 +1,14 @@ | |||
|
|
|||
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.
Please remove this empty line.
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.
Done.
| ARCHS = arm64; | ||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| DEVELOPMENT_TEAM = 3GRKCVVJ22; | ||
| DEVELOPMENT_TEAM = 9FK3425VTA; |
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.
Please remove the DEVELOPMENT_TEAM lines.
| } | ||
|
|
||
| // -- Photo -- | ||
| // Choose Photo from Gallery |
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.
These comments provide very little information on top of the name of the method.
| } | ||
|
|
||
| // -- Video -- | ||
| // Choose Video From Gallery |
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.
These comments provide very little information on top of the name of the method.
| @@ -0,0 +1,14 @@ | |||
| { | |||
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.
Should the .vscode/ folders be .gitignored or are they intended to be shared between developers using that IDE?
packages/image_picker/CHANGELOG.md
Outdated
| ## 0.4.2 | ||
|
|
||
| * Added Video Capability with `pickVideo`. | ||
| * Updated Example for Preview of Video Captured |
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.
Please use full verb phrases using standard US spelling and capitalization. E.g.
* Added support for picking videos.
* Updated example app to show video preview.
mravn-google
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.
Thanks!
| ..initialize() | ||
| ..setLooping(true) | ||
| ..play(); | ||
| setState(() {}); |
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.
- By convention, state changes are made within the lambda given to
setState. Not that it matters much to runtime behavior, but because emptysetState(() {})calls like this are very easy to overlook, forget, or place where not needed. I believe an early version of Flutter had amarkNeedsBuild()method or similar which was replaced bysetStatefor exactly this reason. - Since
setStateis called on completion of thepickVideofuture, theStatewe're in may have been unmounted in the meantime. We therefore need to guard the call tosetStatewith a check on themountedproperty:An alternative is to use aif (file != null && mounted) { setState(() { _controller = ... }); }
FutureBuilderas for images. It does the mounted check internally.
| @@ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
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.
Please remove eclipse artifacts from the repo (.classpath, .project, .settings/).
.gitignore
Outdated
| .dart_tool | ||
| .dart_tool | ||
| packages/image_picker/.vscode/launch.json | ||
| packages/image_picker/.vscode/settings.json |
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 don't want plugin-specific lines in the repo-level .gitignore. Please replace these two lines by
.vscode/| @@ -0,0 +1,19 @@ | |||
| { | |||
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.
Please remove file.
FYI, #588 adds the needed .gitignore for .vscode/ to the repo root.
| @@ -0,0 +1,17 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
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.
Please remove file.
| @@ -0,0 +1,2 @@ | |||
| #Thu May 24 08:04:52 EDT 2018 | |||
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.
Please remove file.
| @@ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
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.
Please remove file.
| @@ -0,0 +1,23 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
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.
Please remove file.
| @@ -0,0 +1,2 @@ | |||
| #Thu May 24 08:04:52 EDT 2018 | |||
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.
Please remove file.
| } | ||
| } | ||
|
|
||
| class AspectRatioVideo extends StatefulWidget { |
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.
Could we reduce code duplication from video_player/example to the bare minimum, please?
The image_picker example should be focused on the functionality of image/video picking, not video playback. I think having the AspectRatioVideo widget here is OK, but I don't think we need play/pause controls for this example. And the buildCard method further below is not used at all.
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.
Okay sounds good. View-Only of the video works too. I had brought that over from the video player example because when the video is looping it will play noise and the user may want to silence it. But it should be up to the developer to implement playback anyway. I can remove everything but the viewer.
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.
Thanks. The merge conflict happens because I just removed all .gitignore files except the repo root one.
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.
Ok I resolved the conflict. Vscode seems to generate a lot of extra files everytime the project is run. Ill see if Android Studio is doing the same thing
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 why Vscode generates eclipse project files?
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.
Not sure. maybe an extension in Vscode doing it. Ill check it out.
mravn-google
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 new Container(); | ||
| } | ||
| } | ||
| } |
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.
Please add empty line at the end of the file.
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.
When I add an empty line it failed the format test?
.gitignore
Outdated
| GeneratedPluginRegistrant.h | ||
| GeneratedPluginRegistrant.m | ||
| GeneratedPluginRegistrant.java | ||
|
|
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.
No need for this change.
|
I get an exception when picking an image: |
|
Go into the app settings to enable all permissions, I will double check it’s requesting the permissions correctly and update as necessary. It is working for me on the Google Pixel which android phone are you testing on? I had had this error when i didn’t have read/write storage permissions granted one time. |
|
@AppleEducate Turns out I had the System/Developer options/Don't keep activities option enabled on my Nexus 5X, so the Flutter activity was killed as soon as I launched the native counterpart. The plugin isn't working in this situation on master either, cf. flutter/flutter#17950. |
|
Gotcha! Good to know 👍🏻 |
|
Hi @AppleEducate , do you know if the issue that you mentioned was fixed?
|
I have added the ability to select and capture photos and videos using the stock UI on Android and iOS.