Android and iOS Gallery Integration #337
-
Hey new to this project, but so far it's been really helpful! One thing that took me a while to understand though was after taking video I couldn't see it in the standard iOS and Android photo galleries/viewers which depend on it being saved in specific location on both devices. I'm still a little new to flutter so this could be 100% due to my ignorance, but it seems like a little bit of a missed opportunity that the builder for awesomecamera doesn't allow for easy integration with libraries that are made for saving into these necessary locations in order to be viewed on their respective devices easily. The way I got it to work is by updating the library code (which i know is already kinda "hacky") for the package in order to control where the file is saved by modifying the
and after adding in the update I now had the ability to save the media using a library made to do so across devices and which easily allows for viewing in their respective photo viewers on android and ios. So i guess my question after all that is did I unnecessarily do this workaround and there's already a better way i can work with the package to achieve the same results, or would it require some updates to make this happen? Thanks in advance to any one willing to help :)! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Instead of modifying directly CamerAwesome, you can listen to the pictures taken and react to that: StreamSubscription<MediaCapture?>? _captureStateSubsciption;
CameraAwesomeBuilder.awesome(
// Other params
previewDecoratorBuilder: (state, _, __) {
_captureStateSubsciption?.cancel();
_captureStateSubsciption = state.captureState$.listen((event) {
if (event?.status == MediaCaptureStatus.success) {
GallerySaver.saveVideo(basenameWithoutExtension(event.filePath));
}
});
return SizedBox.shrink();
},
); Note that you can setup the listener in any builder that exposes a I don't think we'll add this directly in the lib since it does already a lot of things and this feature can be added easily with the help of other packages. |
Beta Was this translation helpful? Give feedback.
-
Your subscribe suggestion worked perfectly! I was able to get it to work with the following code snippet.
Only potential issue with this is |
Beta Was this translation helpful? Give feedback.
The
cameraContext
is intended for private behaviours, but you may use it in some special cases. There are discussions to wether we should expose a kind of controller similar to thiscameraContext
or not.In your case however, you can just use the
event
parameter passed to thelisten
method. It should have thefilePath
👍