-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Adding Video Capability to image_picker #565
Changes from 7 commits
e81b561
6f35340
3b660f5
a1143e4
54c3f68
4f3b1c3
74f775d
1fb8bf7
86d5e88
eaa2f8d
c6e35da
7e83b8f
ae48534
97bc60d
95b6bb3
d7d342e
ffe05d0
06d837e
9754383
ddd770c
a2ee99d
fd38d12
bfc5dc9
3a2f735
883f99d
dd9ef1f
111d568
16ea638
2a30285
af2d018
ce609b4
cd7e45f
d56aa5a
e4c025b
5a580bf
8161e02
e0f0d62
f8ffc37
b39d2fa
a67bf89
9f73d2d
e1b1075
1ce00fb
f962130
494de63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,6 @@ GeneratedPluginRegistrant.m | |
|
|
||
| GeneratedPluginRegistrant.java | ||
|
|
||
| .dart_tool | ||
| .dart_tool | ||
| packages/image_picker/.vscode/launch.json | ||
| packages/image_picker/.vscode/settings.json | ||
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
||
| <classpath> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
| <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>image_picker</name> | ||
| <comment>Project image_picker created by Buildship.</comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| <nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
| </natures> | ||
| </projectDescription> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #Thu May 24 08:04:53 EDT 2018 | ||
| connection.project.dir=../example/android |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
||
| <projectDescription> | ||
| <name>android</name> | ||
| <comment>Project android created by Buildship.</comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
| </natures> | ||
| </projectDescription> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #Thu May 24 08:04:52 EDT 2018 | ||
|
||
| connection.project.dir= | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
||
| <classpath> | ||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
| <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
||
| <projectDescription> | ||
| <name>app</name> | ||
| <comment>Project app created by Buildship.</comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| <nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
| </natures> | ||
| </projectDescription> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #Thu May 24 08:04:52 EDT 2018 | ||
|
||
| connection.project.dir=.. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ class MyHomePage extends StatefulWidget { | |
| } | ||
|
|
||
| class _MyHomePageState extends State<MyHomePage> { | ||
| Future<File> _mediaFile; | ||
| Future<File> _imageFile; | ||
| bool isVideo = false; | ||
| VideoPlayerController _controller; | ||
| VoidCallback listener; | ||
|
|
@@ -45,17 +45,19 @@ class _MyHomePageState extends State<MyHomePage> { | |
| _controller.removeListener(listener); | ||
| } | ||
| if (isVideo) { | ||
| _mediaFile = ImagePicker.pickVideo(source: source).then((File _file) { | ||
| _controller = VideoPlayerController.file(_file) | ||
| ..addListener(listener) | ||
| ..setVolume(1.0) | ||
| ..initialize() | ||
| ..setLooping(true) | ||
| ..play(); | ||
| setState(() {}); | ||
| ImagePicker.pickVideo(source: source).then((File file) { | ||
| if (file != null) { | ||
| _controller = VideoPlayerController.file(file) | ||
| ..addListener(listener) | ||
| ..setVolume(1.0) | ||
| ..initialize() | ||
| ..setLooping(true) | ||
| ..play(); | ||
| setState(() {}); | ||
|
||
| } | ||
| }); | ||
| } else { | ||
| _mediaFile = ImagePicker.pickImage(source: source); | ||
| _imageFile = ImagePicker.pickImage(source: source); | ||
| } | ||
| }); | ||
| } | ||
|
|
@@ -106,7 +108,7 @@ class _MyHomePageState extends State<MyHomePage> { | |
|
|
||
| Widget _previewImage() { | ||
| return FutureBuilder<File>( | ||
| future: _mediaFile, | ||
| future: _imageFile, | ||
| builder: (BuildContext context, AsyncSnapshot<File> snapshot) { | ||
| if (snapshot.connectionState == ConnectionState.done && | ||
| snapshot.data != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
|
|
||
| // Copyright 2017 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
@@ -130,17 +129,6 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |
| NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; | ||
| UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; | ||
| [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; | ||
| if (image == nil) { | ||
| image = [info objectForKey:UIImagePickerControllerOriginalImage]; | ||
| } | ||
| image = [self normalizedImage:image]; | ||
|
|
||
| NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; | ||
| NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; | ||
|
|
||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; | ||
| } | ||
|
|
||
| if (videoURL != nil) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we avoid working on the image above, if |
||
| NSData *data = [NSData dataWithContentsOfURL:videoURL]; | ||
|
|
@@ -157,6 +145,18 @@ - (void)imagePickerController:(UIImagePickerController *)picker | |
| details:nil]); | ||
| } | ||
| } else { | ||
| if (image == nil) { | ||
| image = [info objectForKey:UIImagePickerControllerOriginalImage]; | ||
| } | ||
| image = [self normalizedImage:image]; | ||
|
|
||
| NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; | ||
| NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; | ||
|
|
||
| if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { | ||
| image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; | ||
| } | ||
|
|
||
| NSData *data = UIImageJPEGRepresentation(image, 1.0); | ||
| NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; | ||
| NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; | ||
|
|
||
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.