Hi Gerald. I implemented this method to my application. However, how to save it on the local database? Should I convert photo into the bytes and arrays? And how to do it. I am stuck there at the moment. And I can not find any clear explanation regarding the matter
Sorry for the late response Patrick, I hope you got it figured out by now. Saving an image to a database is something you typically don't want to do. You would want to save the image to the filesystem or somewhere online and then save the path to the image in the database. Hope that helps!
Hi Gerald, CapturePhotoAsync is not supported on iOS simulators. It will only run on a physical device? I've tried your repo as well. Is there any way around this?
Hi @Gerald, thank you for this great video. I was wondering if I can find some more content about how to use the camera record videos and to broadcast live (like in a video chat). Do you have any content about the video part? thank you!.
Hi Gerald. Really nice video explaining how to use the MediaPicker in a simple way. I have a question tho, how can we control the lifecycle events (like on suspend or on resume) when you actually suspend the app while being on the camera or in the media picker itself (Not in the app which is in the background while the camera / picker are on)
thank you Gerald Versluis Your teaching gave me great help in learning XAMARIN I have a question When I was practicing this MediaPicker I use the photos I selected to save into ImageSoure in a Model when I change the page and try to see the ModelDetailPage the APP STOP (System.ObjectDisposedException:'Cannot access a disposed object. Object name:'Stream has been closed'.') I try many ways but still can't find the solution is it because the Stream not working finish and I change the page to make Stream close?? ([System] A resource failed to call close. **System.ObjectDisposedException:** 'Cannot access a disposed object. Object name: 'Stream has been closed'.') but I try this idea to fix but I no have the solution if you know how to do please give me the idea, thank you so much
It's kind of hard to know without the code :) But this seems like you're accessing the stream already and when you do you have to reset the position. Or maybe you are inside a using statement? Outside of it the stream will be exposed. Dive deeper in how streams work exactly that might be helpful! You can also join my Discord server where there are like-minded people helping each other out and chatting
Hi, i am using mediapicker to save path to picture on android to database and then load it to variable and when i write that variable to image source it shows nothing. But when i copy that url from database and write that path directly in source and not to variable it works. Can you please help me?
I’m not sure what you mean, sorry. If you could provide a little sample project or something on GitHub that would be helpful and I could take a look :)
Hi Gerald, great video many thanks. In my app I want to start a Media Picker photo or video using a timer so the user doesn't need to press the button. I don't want the user to have to go to the phone camera settings to setup a timer but instead control everything from my app. Is this possible?
Hi, I beleive this API is based on 🐒 James Montemagno media plugin, can we still access compression quality? var caramaFile = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "Photo", SaveToAlbum = true, CompressionQuality = 75, CustomPhotoSize = 50, PhotoSize = PhotoSize.MaxWidthHeight, MaxWidthHeight = 2000, DefaultCamera = CameraDevice.Rear });
It is definitely based on that but they didn’t implement all the options of the MediaPlugin yet. So if you need that, keep using the media plugin for now
Is it possible to have one button that will open an 'open with..' window [which looks like the ShareScreen] and populate all the available apps there [camera, gallery, file system. etc...]?
Again a great video! One question: with the media plugin from James Montemagno one can also resize/compress/crop the images. Unfortunately, he stoped support in december 2020. What would be the best way to this related with the mediapicker of Xamarin.Essentials?
Thanks so much! Yeah that's unfortunately that that wasn't ported. I'm hoping to get it into .NET MAUI Essentials asap but it might take a while. We're considering making it part of the .NET MAUI Community Toolkit first
Excellent question! I don't know to be honest. I would expect the platforms to have something for this. Maybe open an issue on the Essentials repo if there isn't one already so they can provide an API for it
@@jfversluis Xamarin.Essentials is updated to v1.7.5, but still when request for storage permission it is denied , only the camera permission is asked. it is ok when target android verison is 12
Great that you're putting this to use! You should be able to just pick the image and either copy that to your app sandbox and show it directly? This is not much information to go on unfortunately. I'm sure you can figure it out!
@@jfversluis thanks for your response nope , I mean I want to pick images from phone's gallery, I used this FilePicker instead of ImagePicker for multiselect option
If you’re using the filepicker it’s not possible to bring up the gallery. So I guess you’ll have to wait for Essentials to support it or roll your own solution. Sorry :(
Hi Gerald, how is with image rotation bug in this component? It seems to not be fixed and Old Xam.Media.Plugin has another bug. I don't find any solution for whole year.
Hi Gerard, I use the MediaPicker.CapturePhotoAsync on a Mac, which should be supported according the documentation (using the essentials 1.6 RC-1). But it instantly returns a FeatureNotSupportedException. What am I doing wrong?
@@MegaDegraaf Could you show me the Docs where it says that? Looking at the code that is not something that is supported: github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/MediaPicker/MediaPicker.macos.cs#L10
@@MegaDegraaf Opened a PR to fix that: github.com/MicrosoftDocs/xamarin-docs/pull/3190 So, either the Docs will be updated and sorry for the confusion, or I will be proven wrong :D
First of all, thanks for your videos, I have learnt a lot! I'm wondering if it's possible to have an image as "filter/overlay" over the camera view? I guess MediaPicker ain't the way to go if that's what I want to do.. Do you have any suggestion for fulfilling my wish?
Sure! CameraView is just another element so just add it to a grid with a row span of 3 for instance and put something in row 1 and 3 and you have an overlay :)
Ah my mistake! Yeah I was :) you said CameraView and now automatically I think about the Toolkit 😅 no this is not possible with MediaPicker not right now anyway
@@jfversluis haha my bad, some words just should not be put together ;) Okay thank you, I will look into the toolkit, saw you had a stream about it! :)
Hello, thanks for sharing knowledge about xamarin. I have a problem with my solution, can you help me? I'm testing it on a Samsung XT205 device (A8 tablet), when I open the camera or select the file, my application closes without throwing an error message. Any idea what it could be? From Brazil, thank you very much!
Thank you! Without any error it’s near impossible to do anything. Closely inspect your application output logs Android tends to put a lot of good information in there. Good luck!
Hey I have a question, i get an error when i press the take picture button. It says Xamarin.Essentials.PermissionException: 'StorageRead permission was not granted: Denied'. Do you know how to fix this?
If you’re targeting api 33 you probably want to update to version 1.7.5 that just came out and it might fix it. Otherwise, make sure you have the permissions set up correctly
I am trying to implement CapturePhotoAsync but after a picture is taken and accepted, xamarin essentials throws a nullreferenceexception and I have no clue how to fix this. Do you have any suggestion?
That’s how the photo is taken originally. Unfortunately, we can’t do anything about it right now. You probably want to use MediaPlugin or MediaGallery right now
@@jfversluis Ok well what I do I send my pic to an API and that API has a function to autorotate it that helped me. Weird that xamarin makes it so complex to even rotate a picture :D
Nice job as usual, i was wandering if you could do the same example for MAUI, because I have some trouble with and I gave up to take a photo on MAUI. If you could help it would save me. Thanks!
Hi Gerald, Hi Gerald if I want to use Binding and not x:name how should I use it? when using x:name is not displayed in the viewModel :( resultImage.Source
Gerald Versluis thank you and we want to add the watermark while saving image (after taking Live Photo from Xamarin app ) to gallery in android and iOS.
I have been trying to use this to get the selected image into an Essentials email as attachment but so far no luck. Where would I find examples of this being done?
@@jfversluis I got it working with FilePicker.PickMultipleAsync after some messing around and finding out i cant seem to step through an array in C# like i can in powershell but maybe as things move forward i will circle back around to MediaPicker
This is great, Gerald! Can I implement all or most common Xamarin tools, plugins, or NuGet packages similarly? You know, I'm a curious novice with loads of naive questions!
Thank you for the video. Was very useful but, I can't install the versión 1.6, in the nuget packages appear only the version 1.5.X. I have Microsoft Visual Studio Professional 2019 Version 16.7.4. Any clue? Thank you.
Hey Carlos! Absolutely, at this time 1.6 is in pre-release. In the screen to install nuget packages check the “show pre-releases” box and it should show up :) Thanks for watching!
Hello Gerald ... I really liked your video, well explained and with great didactics ... It is possible for me to open the camera and take a photo without pressing the camera button ... in automatic mode ... after I pressed the button in my application it already opens the camera, takes the photo and returns the image without pressing any button ?
Thank you Alexander! Much appreciated! That is not possible with the MediaPicker, however! There is the Xamarin Community Toolkit (github.com/xamarin/XamarinCommunityToolkit/ in preview right now) which has the CameraView which should be able to do that
While camera opened we loose app context, i mean onresume is not working if i minimize the app and and reopen it. Can we do something to get onresume when camera is open?
Thanks for very informative content. Nice to see new xamarin-focused channel, there still too few of them (especially of such a good quality). I'm currently implementing media picker in my project so your video couldn't have been published in better time 🙂 Perhaps you know how to pick both video and photo at once? I see only separate methods and imo having 2 buttons (1 to pick photo, 2 to pick video) on small screen is rather peculiar 🙂
Thank you for the kind words Robert! Appreciate it! There is no way of picking both at the same time. At least not with the current version. So I guess you’d have to find a different solution. Maybe have 1 button “pick file” or “pick image/video” and then first show a pop-up that lets people choose between one or the other. Not ideal, but better than nothing I guess! And I happen to know that Essentials gladly accepts pull requests ;)
That’s probably because the picture was taken that way. The MediaPlugin had a method to automatically rotate, that didn’t make it into Essentials (yet). Maybe there is the rotation angle property that you can use to show it correctly?
@@jfversluis Hi Gerald - thanks for the great videos. I am using Essentials 1.7.0. Photo Capture for iOS rotates all images 90 degrees automatically. I've seen that others have also experienced this. Any rumors on when this might be addressed? All the workarounds to rotate back cause a lot of overhead. Thanks!
Thanku so much your videos are really helpful and informative.I want to design a circular image which is editable just like profile picture pick from gallery and capture from camera so can u provide any idea on it??
Thank you! I don't believe there is a library out there. Maybe Telerik or Syncfusion or some third-party like that has something for it? Did you find something yet?
I'm not sure if it's supposed to work right now, at least for .NET MAUI. Right-click the file and select Open With. See if there is a GUI option in there.
Hi Gerald, you did it again fantastic video. I have been playing with the Media player, what I found out is when is running on a physical device on IOS when a picture is taken it actually reverse the image and when you put the phone on landscape mode it actually put the image upside down, any idea what can be the solution? I will investigate and see if I find a solution for it. It's seems only to be be working properly on landscape mode clockwise, interesting.
Thanks David! You mean MediaPicker I assume? Yeah interestingly enough there was a method in the MediaPlugin for this... something like GetAndRotateImage or something. You could try and use the MediaPlugin which is the exact same thing but the MediaPicker is still missing a few pieces, they’re working on porting that :)
@@daredevilpantera alright! Great! Then just use that until they moved everything over. Or, of course, if you’re brave enough contribute that yourself 😉
I think all of your videos are great. I just want to ask if you know some sources where I could study C#, Xamarin, and all that I need to build a mobile app. In my mobile app, I need a server that handles push notification and receives image from the user (as much as possible, I want the server to automatically push notifications to specific users). Can you recommend me some books or any sources where I could learn more about developing a mobile app with that kind of features? I really don't know where to start and where should I learn those. I want to be like you who knows a lot more about developing a mobile app.
I really want to join your channel. But first, I want to be confident on my knowledge and skills by studying by myself before I could interact with you. The problem is I don't know what should I study to have a concrete knowledge about developing a mobile app using Xamarin. There are lots of things I want to learn so that I could easily communicate to you my questions and ideas.
Great Meloi! And I'm glad you found my channel. I hope the content will serve you well. In terms of learning Xamarin, it depends. I feel like that you learn most by doing. There is the official channel ua-cam.com/users/xamarindevelopers that has a lot of great content, also for beginners, check out the Xamarin 101 series. Then the Docs, I think are pretty amazing as well. I think there is also an e-book on there docs.microsoft.com/en-us/xamarin/ For blog posts you can have a look at planetxamarin.com which aggregates a lot of blogs from the community and from there just click through to their pages and other resources mentioned in there. And I think finally, have a look at all the GitHub repos people are putting out there to see what people are creating. Hope this helps!
Outstanding video! When I try to upload a video from the album on iOS, microphone permissions are prompted. I read that it's a bug. Any idea when Xamarin Essentials will be updated? Thanks!
Thank you Larry! Appreciate it! To be honest I don't know. It's been a while since a version was released, I feel they are focussed on .NET MAUI/.NET 6 at this time
@@lfeldmantutoring Oooh is that right? That is so funny! There is actual 2 other Gerald Versluis's in the Netherlands who both also work in IT 😅 Wow Larry! That is so nice of you! Thank you for supporting me! Make sure to join the Discord if that's something you like :) discord.gg/ksPeY286
I have an issue here. It default shows the same image from which the photo captured. But its not showing from the URL i supplied to. Captured in one phone is not showing in another phone. URI coming from server and supplied to image source but it shows one the one which captured from that phone it self. Is something related to cache?
@@jfversluis I ran the app two devices: 1. iphone i took a capture and stored in the server. 2. in android if i open the screen image is blank, but I am pulling URI from the server. If i take a capture in this device it shows the capture of this phone. 3. If I open iphone again it shows ony iphone captred image not the one from android 4. If i open the andorid again it shows only the android captured image not the one from iphone I am pretty sure the image is stored in server and woring.
Great Video! Do you happen to know how to convert the StreamImageSource into a string, so I can save the source in a database (in an model/entity)? Or is there a more elegant way to solve this? Sorry for trying to "outsource" this info, I haven't come up with any solution for this usecase yet... I really appreciate your help and the value you create with tutorials like these! Keep it up :)
Thanks for the kind words! Personally I think saving images to a database is a bad idea. You want to save the image on disk and then save the path to it in the database. If you really want to do it, I guess you'll have to convert it to a Base64 string
@@jfversluis Wow that was a quick reply! Yes, that's exactly what I was planning all along. I just had trouble finding a way to convert the StreamImageSource to a string. I haven't found any suitable methods in the StreamImageSource object to do so. Converting a FileImageSource to string seems much simpler in contrast. I'll try some more with Base64 string then. Thanks!
@@jfversluis , it is also my goal, therefore this is my reply: I need to use the image as a "profile image", so I would like to store it somewhere (and somehow) in order to load and show everytime my Xamarin App is opened... But this is the point of view and the strategy that i am thinking about, maybe there are better ones. Thanks in advance
I think that is nearly impossible for free since that are very extensive tools. Are you aware that SuncFusion offers community licenses which are free if you’re a small developer? I think they have some controls that might be what you’re looking for :)
@@jfversluis Thanks for reply. can we make pdf with WebView control in Xamarin, or can you please make a tutorial on it title: Make pdf of html page using WebView in Xamarin.Forms. i have follow different documentations for this purpose but nothing done.
async void Button1_Clicked(System.Object sender, System.EventArgs e) { var result = await MediaPicker.CaptureVideoAsync(); if (result != null) { var stream = await result.OpenReadAsync(); resultImage.Source = ImageSource.FromStream(() => stream); } } The Android device does not display it.
Thank you very much Gerald, you saved me. I SMASHED that big red beautiful subscribe button. Now I also ran into a little snag, the image I capture is not automatically saved, no errors shown, just doesn't save it, what do you suspect could be the issue?
Thanks! Appreciate it! There is no issue, I think this doesn’t save it automatically :) so either save it somewhere yourself, or if you want to save it to the gallery you might want to check this one: ua-cam.com/video/8JvgnlHVyrI/v-deo.html
Hello, Sorry but I keep getting this error when running the code, and I can't seem to find a solution: 'Method not found: bool Xamarin.Forms.Internals.ResourceLoader.get_IsEnabled()'
@@jfversluis Hello yea, I think the problem was that I needed to ensure I was using Version 10 of Android or something... I don't really know to be honest I just changed the version to 10 and removed the NuGet packages and them re-built the solution and like magic it worked! Thanks for the Video it was Great :D
Very helpful video, but i'm having an error. whenever I press the button to pick a photo, i get an error. System.TypeLoadException: 'Could not load type of field 'IMS.Returns.frmTakePhoto+d__1:5__2' (6) due to: Could not resolve type with token 010000a3 from typeref (expected class 'Xamarin.Essentials.FileResult' in assembly 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Xamarin.Essentials.FileResult member:(null)' I tried googling it, but I got nothing I understood. Thanks!
This usually happens when the versions on the different projects don’t line up. Please check if you have the same version of Essentials installed on your shared project as well as your platform projects
@@dotnettohard ah I think I misunderstood. It would be possible, but I don’t know if any library that does that right now so you would have to write platform code for that
@@jfversluis when I capture an image using camera the compression ratio should be 40% . is there any possibility to do this using Xamarin essentials ? This image should not be stored in the users mobile storage.
Sorry to hear that! :( Looks like this issue is reported here: github.com/xamarin/Essentials/issues/1481 Make sure to add to that with all the details you can find!
Thanks for this video Your Videos Is Very Help Full for me Sir this is Working Fine In my Emulator and capture Image nd save local storage But Not Working on my Android real device should be work in my device?
In android debug mode works perfectly but when is in release mode and then Archive to create the apk, give me this error: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Xamarin.Essentials.FileResult' (defined in assembly , Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Xamarin.Essentials.FileResult at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
github.com/jfversluis/XFEMediaPickerSample this sample code error (Take Image). "System.NullReferenceException: Object reference not set to an instance of an object."
What is the next Essentials API I should do a video about?
geolocation for tracking position on a map.
Rajesh Jha will do!
recording videos from forms in a custom view would be awesome :) ie. record 15 seconds of video
@@syanidester We've added CameraView to the Xamarin Community Toolkit which can record videos and save that, would that be interesting?
@@jfversluis that sounds awesome gerald
Exactly what I was looking for. Thank you
Glad I could help!
Is it possible to add a frame in the camera, to adjust the image for example a card and automatically trigger the photo?
Thank you very much
Hi Gerald. I implemented this method to my application. However, how to save it on the local database? Should I convert photo into the bytes and arrays? And how to do it. I am stuck there at the moment. And I can not find any clear explanation regarding the matter
Sorry for the late response Patrick, I hope you got it figured out by now. Saving an image to a database is something you typically don't want to do. You would want to save the image to the filesystem or somewhere online and then save the path to the image in the database. Hope that helps!
Hi Gerald, CapturePhotoAsync is not supported on iOS simulators. It will only run on a physical device? I've tried your repo as well. Is there any way around this?
Unfortunately not. The iOS simulator has no way of emulating a camera
Hello.Thanks for this video but i was wondering if we can use this to capture multiple photos in and then select ok and send those pictures to api?
Hi @Gerald, thank you for this great video.
I was wondering if I can find some more content about how to use the camera record videos and to broadcast live (like in a video chat). Do you have any content about the video part?
thank you!.
I think you sent me an email, let's talk a little there!
Hi Gerald. Really nice video explaining how to use the MediaPicker in a simple way. I have a question tho, how can we control the lifecycle events (like on suspend or on resume) when you actually suspend the app while being on the camera or in the media picker itself (Not in the app which is in the background while the camera / picker are on)
thank you Gerald Versluis
Your teaching gave me great help in learning XAMARIN
I have a question
When I was practicing this MediaPicker
I use the photos I selected to save into ImageSoure in a Model
when I change the page and try to see the ModelDetailPage
the APP STOP
(System.ObjectDisposedException:'Cannot access a disposed object.
Object name:'Stream has been closed'.')
I try many ways but still can't find the solution
is it because the Stream not working finish and I change the page
to make Stream close??
([System] A resource failed to call close.
**System.ObjectDisposedException:** 'Cannot access a disposed object.
Object name: 'Stream has been closed'.')
but I try this idea to fix but I no have the solution
if you know how to do please give me the idea,
thank you so much
It's kind of hard to know without the code :)
But this seems like you're accessing the stream already and when you do you have to reset the position. Or maybe you are inside a using statement? Outside of it the stream will be exposed. Dive deeper in how streams work exactly that might be helpful!
You can also join my Discord server where there are like-minded people helping each other out and chatting
Can you do a video on creating a Xamarin.forms video recorder with custom controls. I noticed that the Xamarin samples from Microsoft are outdated.
Which samples are that? Did you see the CameraView in the Xamarin Community Toolkit? I am definitely planning videos on controls in there :)
Hi, i am using mediapicker to save path to picture on android to database and then load it to variable and when i write that variable to image source it shows nothing. But when i copy that url from database and write that path directly in source and not to variable it works. Can you please help me?
I’m not sure what you mean, sorry. If you could provide a little sample project or something on GitHub that would be helpful and I could take a look :)
Hi Gerald, great video many thanks. In my app I want to start a Media Picker photo or video using a timer so the user doesn't need to press the button. I don't want the user to have to go to the phone camera settings to setup a timer but instead control everything from my app. Is this possible?
Hello, thank for this video. Can i replace image with imageview ?
If so, how should I replace it ?
What is ImageView? Is that from another library?
@@jfversluis Im using Xamarin Android
Ah! Sure, you should be able to. Not sure how though. You’d have to get the native image object from the stream I guess :)
okay,
Thanks
Hi, I beleive this API is based on 🐒 James Montemagno media plugin, can we still access compression quality?
var caramaFile = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
Directory = "Photo",
SaveToAlbum = true,
CompressionQuality = 75,
CustomPhotoSize = 50,
PhotoSize = PhotoSize.MaxWidthHeight,
MaxWidthHeight = 2000,
DefaultCamera = CameraDevice.Rear
});
It is definitely based on that but they didn’t implement all the options of the MediaPlugin yet. So if you need that, keep using the media plugin for now
@@jfversluis I see the word "yet" in your reply, so there is potential to add this?
I’ve asked about this and they said they just added the basics but the rest will be added in the future. They didn’t say when though :)
Is it possible to have one button that will open an 'open with..' window [which looks like the ShareScreen] and populate all the available apps there [camera, gallery, file system. etc...]?
Again a great video! One question: with the media plugin from James Montemagno one can also resize/compress/crop the images. Unfortunately, he stoped support in december 2020. What would be the best way to this related with the mediapicker of Xamarin.Essentials?
Thanks so much! Yeah that's unfortunately that that wasn't ported. I'm hoping to get it into .NET MAUI Essentials asap but it might take a while. We're considering making it part of the .NET MAUI Community Toolkit first
Any news on this?
Hi Gerald, can you tell me how to get a thumbnail from a video capture? Thanks!
Excellent question! I don't know to be honest. I would expect the platforms to have something for this. Maybe open an issue on the Essentials repo if there isn't one already so they can provide an API for it
If the target android version is 13 then these read/write storage permission is not working, any solution?
That should be fixed with the latest Xamarin.Essentials release.
@@jfversluis Xamarin.Essentials is updated to v1.7.5, but still when request for storage permission it is denied , only the camera permission is asked. it is ok when target android verison is 12
Hi Gerald, I'm trying to pick one image at a time and display all picked images in a list. Can you please help me how can I achieve this?
Great that you're putting this to use! You should be able to just pick the image and either copy that to your app sandbox and show it directly? This is not much information to go on unfortunately. I'm sure you can figure it out!
Could you please show guideline how to get loaded image insert into SQL Server Database?
Typically databases aren’t meant for images. Save the image to disk or a storage service and save the file path or url to the database
Hi Gerald, thanks for the videos, does MediaPickerOptions support multi picking images?
I don't think it does at this time. If you need that, you can use the FilePicker: ua-cam.com/video/4gV9ZV61rn4/v-deo.html
@@jfversluis how to redirect the path to photo gallerias ?
@@muhammedhedyia7258 I'm not sure what you mean. You want to save the image to the gallery?
@@jfversluis thanks for your response nope , I mean I want to pick images from phone's gallery, I used this FilePicker instead of ImagePicker for multiselect option
If you’re using the filepicker it’s not possible to bring up the gallery. So I guess you’ll have to wait for Essentials to support it or roll your own solution. Sorry :(
Hi Gerald, how is with image rotation bug in this component? It seems to not be fixed and Old Xam.Media.Plugin has another bug. I don't find any solution for whole year.
It is considered a not implemented feature not a bug 😉 but I have it on my radar and want to fix it asap for .NET MAUI
Hi Gerard, I use the MediaPicker.CapturePhotoAsync on a Mac, which should be supported according the documentation (using the essentials 1.6 RC-1). But it instantly returns a FeatureNotSupportedException. What am I doing wrong?
Did you also install the plug-in on your macOS project?
@@jfversluis Of course. For example, the media picker works like a charm (PickPhotoAsync).
@@MegaDegraaf Could you show me the Docs where it says that? Looking at the code that is not something that is supported: github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/MediaPicker/MediaPicker.macos.cs#L10
@@jfversluis docs.microsoft.com/en-us/xamarin/essentials/platform-feature-support - At media pickerthere is a green button (full support) with macOS.
@@MegaDegraaf Opened a PR to fix that: github.com/MicrosoftDocs/xamarin-docs/pull/3190
So, either the Docs will be updated and sorry for the confusion, or I will be proven wrong :D
First of all, thanks for your videos, I have learnt a lot! I'm wondering if it's possible to have an image as "filter/overlay" over the camera view? I guess MediaPicker ain't the way to go if that's what I want to do.. Do you have any suggestion for fulfilling my wish?
Sure! CameraView is just another element so just add it to a grid with a row span of 3 for instance and put something in row 1 and 3 and you have an overlay :)
And thank you for the kind words!
Thanks for quick resonse! I got it! But are you reffering to CameraView as in Xamarin community toolkit?
Ah my mistake! Yeah I was :) you said CameraView and now automatically I think about the Toolkit 😅 no this is not possible with MediaPicker not right now anyway
@@jfversluis haha my bad, some words just should not be put together ;) Okay thank you, I will look into the toolkit, saw you had a stream about it! :)
Underrated channel bro
Appreciate that! Spread the word ;)
Hello, thanks for sharing knowledge about xamarin.
I have a problem with my solution, can you help me?
I'm testing it on a Samsung XT205 device (A8 tablet), when I open the camera or select the file, my application closes without throwing an error message. Any idea what it could be? From Brazil, thank you very much!
Thank you! Without any error it’s near impossible to do anything. Closely inspect your application output logs Android tends to put a lot of good information in there. Good luck!
Hey I have a question, i get an error when i press the take picture button. It says Xamarin.Essentials.PermissionException: 'StorageRead permission was not granted: Denied'. Do you know how to fix this?
If you’re targeting api 33 you probably want to update to version 1.7.5 that just came out and it might fix it.
Otherwise, make sure you have the permissions set up correctly
It will be nice to have a video to show how to pick the image to save it in a rest server and how to get the metadata from it. :)
THis is probably useful: ua-cam.com/video/KPDGtLeNClQ/v-deo.html
And thank you for being a member! Much appreciated!
I have a question how do i make the camera so that it is only on half the page? so that i can have other stuff under it? thanks
With this you can’t. You then want to look at the CameraView in the Xamarin Community Toolkit
I am trying to implement CapturePhotoAsync but after a picture is taken and accepted, xamarin essentials throws a nullreferenceexception and I have no clue how to fix this. Do you have any suggestion?
O really?! O no! With the exact code as in the demo app?
@@jfversluis Yeah, but I think it's a Xamarin.Essentials problem. So I posted it as a bug there
@@thielenmeister Do you have a link?
I have the same problem :/
@@mischamehrlich159 sorry to hear that. If you can provide me with a sample project that reproduces this behavior I can take a look
Hi Gerarld
How to reduce the photo size.
There used to be something like :
PhotoSize = PhotoSize.Medium
Thanks
That’s not been included here yet :( if you need that keep using the Media Plug-in for now
Why is it saving the picture in rotated byy 90 degrees to the left when I capture a picture?
That’s how the photo is taken originally. Unfortunately, we can’t do anything about it right now. You probably want to use MediaPlugin or MediaGallery right now
@@jfversluis Ok well what I do I send my pic to an API and that API has a function to autorotate it that helped me. Weird that xamarin makes it so complex to even rotate a picture :D
Nothing complex about it. The image control has a rotate property you van use :)
Thank you that very helpful other way how can save the image on the device ? I used CopyToAsync but it's not working
What does "not working" mean? Are you getting an error?
@@jfversluis Actually my images are not added to the gallery App on the phone
Hi, Do you know if there is any way to optimize the sending of the image? When sending the image to the api it takes a long time
The old plugin this is based on had something like that. If you need that now you probably want to use that one.
Nice job as usual, i was wandering if you could do the same example for MAUI, because I have some trouble with and I gave up to take a photo on MAUI. If you could help it would save me. Thanks!
Hi Gerald,
Hi Gerald
if I want to use Binding and not x:name how should I use it?
when using x:name is not displayed in the viewModel :(
resultImage.Source
Create a property of type ImageSource and assign the image to that. Then make a binding to that property from your view :)
@@jfversluis Thank you bro, I'll give it a try 🙏🙏🙏🙏🙏🙏👌
Is it possible to add watermark to the image ?
If yes, could you please provide enough details for android and iOS please ?
Thank you so much
You might be able to do that with SkiaSharp. I will see what I can do :)
Gerald Versluis thank you and we want to add the watermark while saving image (after taking Live Photo from Xamarin app ) to gallery in android and iOS.
I have been trying to use this to get the selected image into an Essentials email as attachment but so far no luck. Where would I find examples of this being done?
Why is it not working? Looking at the code it should be straight-forward since the MediaPicker and the Email APIs use the same object for the file
@@jfversluis I got it working with FilePicker.PickMultipleAsync after some messing around and finding out i cant seem to step through an array in C# like i can in powershell but maybe as things move forward i will circle back around to MediaPicker
Weird, but glad you found a way!
This is great, Gerald!
Can I implement all or most common Xamarin tools, plugins, or NuGet packages similarly?
You know, I'm a curious novice with loads of naive questions!
I’m not sure what you mean, sorry!
Thank you for the video. Was very useful but, I can't install the versión 1.6, in the nuget packages appear only the version 1.5.X. I have Microsoft Visual Studio Professional 2019 Version 16.7.4. Any clue? Thank you.
Hey Carlos! Absolutely, at this time 1.6 is in pre-release. In the screen to install nuget packages check the “show pre-releases” box and it should show up :)
Thanks for watching!
Great! I Got it. Thank you.
Hello Gerald ...
I really liked your video, well explained and with great didactics ...
It is possible for me to open the camera and take a photo without pressing the camera button ... in automatic mode ... after I pressed the button in my application it already opens the camera, takes the photo and returns the image without pressing any button ?
Thank you Alexander! Much appreciated!
That is not possible with the MediaPicker, however! There is the Xamarin Community Toolkit (github.com/xamarin/XamarinCommunityToolkit/ in preview right now) which has the CameraView which should be able to do that
@@jfversluis Thank you ... I'll see this link ...
@@vonbelow45 Let me know if you need anything!
Will this also work on .net MAUI?
If not please can you guide me for the same
This should work exactly the same for .NET MAUI
Thanks for your helpful content, but how can I crop an image while capturing?
Not possible right now. You’ll have to do that afterwards
@@jfversluis Thanks for your reply, can you please make another content on this (crop image)?
While camera opened we loose app context, i mean onresume is not working if i minimize the app and and reopen it. Can we do something to get onresume when camera is open?
Hm I didn't notice this yet... Maybe see if there's an issue for that on the repository and if not open one :)
Thanks for very informative content. Nice to see new xamarin-focused channel, there still too few of them (especially of such a good quality). I'm currently implementing media picker in my project so your video couldn't have been published in better time 🙂 Perhaps you know how to pick both video and photo at once? I see only separate methods and imo having 2 buttons (1 to pick photo, 2 to pick video) on small screen is rather peculiar 🙂
Thank you for the kind words Robert! Appreciate it!
There is no way of picking both at the same time. At least not with the current version. So I guess you’d have to find a different solution. Maybe have 1 button “pick file” or “pick image/video” and then first show a pop-up that lets people choose between one or the other. Not ideal, but better than nothing I guess! And I happen to know that Essentials gladly accepts pull requests ;)
some of the photos that I pick from the gallery get rotated 90 degrees.. any fix for this bug?
That’s probably because the picture was taken that way. The MediaPlugin had a method to automatically rotate, that didn’t make it into Essentials (yet). Maybe there is the rotation angle property that you can use to show it correctly?
@@jfversluis Hi Gerald - thanks for the great videos. I am using Essentials 1.7.0. Photo Capture for iOS rotates all images 90 degrees automatically. I've seen that others have also experienced this. Any rumors on when this might be addressed? All the workarounds to rotate back cause a lot of overhead. Thanks!
Hi, i am stucked MediaPicker line because visual studio compiler writes me that MediaPicker doesnt exists.
Did you install the 1.6 pre-release version of Xamarin.Essentials? ;)
@@jfversluis no, thanks :)
Thanku so much your videos are really helpful and informative.I want to design a circular image which is editable just like profile picture pick from gallery and capture from camera so can u provide any idea on it??
Thank you! I don't believe there is a library out there. Maybe Telerik or Syncfusion or some third-party like that has something for it? Did you find something yet?
How do I open the androidmanifest GUI editor? It does not open for me.
I'm not sure if it's supposed to work right now, at least for .NET MAUI. Right-click the file and select Open With. See if there is a GUI option in there.
@@jfversluis Couldn't find it. But it doesn't really matter, it works anyway. haha
Thank you for your explanation. Really helpful
Glad it was helpful! Let me know if you need anything else :)
Hi Gerald, you did it again fantastic video.
I have been playing with the Media player, what I found out is when is running on a physical device on IOS when a picture is taken it actually reverse the image and when you put the phone on landscape mode it actually put the image upside down, any idea what can be the solution? I will investigate and see if I find a solution for it.
It's seems only to be be working properly on landscape mode clockwise, interesting.
Thanks David! You mean MediaPicker I assume?
Yeah interestingly enough there was a method in the MediaPlugin for this... something like GetAndRotateImage or something. You could try and use the MediaPlugin which is the exact same thing but the MediaPicker is still missing a few pieces, they’re working on porting that :)
@@jfversluis Thanks for the reply I will use the MediaPlugin then.
Let me know if that solves it. Else I can have a look :)
@@jfversluis Sorted, it works like a charm with MediaPlugin, thanks for all the support your a star.
@@daredevilpantera alright! Great! Then just use that until they moved everything over. Or, of course, if you’re brave enough contribute that yourself 😉
I think all of your videos are great. I just want to ask if you know some sources where I could study C#, Xamarin, and all that I need to build a mobile app. In my mobile app, I need a server that handles push notification and receives image from the user (as much as possible, I want the server to automatically push notifications to specific users). Can you recommend me some books or any sources where I could learn more about developing a mobile app with that kind of features? I really don't know where to start and where should I learn those. I want to be like you who knows a lot more about developing a mobile app.
I really want to join your channel. But first, I want to be confident on my knowledge and skills by studying by myself before I could interact with you. The problem is I don't know what should I study to have a concrete knowledge about developing a mobile app using Xamarin. There are lots of things I want to learn so that I could easily communicate to you my questions and ideas.
Great Meloi! And I'm glad you found my channel. I hope the content will serve you well. In terms of learning Xamarin, it depends. I feel like that you learn most by doing. There is the official channel ua-cam.com/users/xamarindevelopers that has a lot of great content, also for beginners, check out the Xamarin 101 series. Then the Docs, I think are pretty amazing as well. I think there is also an e-book on there docs.microsoft.com/en-us/xamarin/
For blog posts you can have a look at planetxamarin.com which aggregates a lot of blogs from the community and from there just click through to their pages and other resources mentioned in there. And I think finally, have a look at all the GitHub repos people are putting out there to see what people are creating.
Hope this helps!
@@jfversluis Wow, this is great. Thanks!
Outstanding video! When I try to upload a video from the album on iOS, microphone permissions are prompted. I read that it's a bug. Any idea when Xamarin Essentials will be updated? Thanks!
Thank you Larry! Appreciate it! To be honest I don't know. It's been a while since a version was released, I feel they are focussed on .NET MAUI/.NET 6 at this time
@@jfversluis Are you related to Jay?
Not that I know of 😅
@@jfversluis Someone named Jay Versluis used to help with iOS development. Anyway, I subscribed as a Senior Developer to your channel.
@@lfeldmantutoring Oooh is that right? That is so funny! There is actual 2 other Gerald Versluis's in the Netherlands who both also work in IT 😅
Wow Larry! That is so nice of you! Thank you for supporting me! Make sure to join the Discord if that's something you like :) discord.gg/ksPeY286
I have an issue here. It default shows the same image from which the photo captured. But its not showing from the URL i supplied to. Captured in one phone is not showing in another phone. URI coming from server and supplied to image source but it shows one the one which captured from that phone it self. Is something related to cache?
I'm not sure if I follow what you're trying to do here, sorry :)
@@jfversluis
I ran the app two devices:
1. iphone i took a capture and stored in the server.
2. in android if i open the screen image is blank, but I am pulling URI from the server. If i take a capture in this device it shows the capture of this phone.
3. If I open iphone again it shows ony iphone captred image not the one from android
4. If i open the andorid again it shows only the android captured image not the one from iphone
I am pretty sure the image is stored in server and woring.
I cleared both the phone caches and uninstalled and working fine now. But don't know how it will react when I go live
@@snjosyula I guess testing software is important after all! It's hard to say where it goes wrong with all these moving parts :)
sir can u make videos about how to capture image using native camera preview, hope to see ur next videos
Just change PichPhotoAsync to CapturePhotoAsync and you can capture an image! :)
I'm getting error at the picphotoasync
Without any details it will be impossible to say something useful 😅
@@jfversluis intelligence is not working at the Mediapicker , it is not showing pickphotoasync, Even if write it manually it showing me an error
Great Video! Do you happen to know how to convert the StreamImageSource into a string, so I can save the source in a database (in an model/entity)?
Or is there a more elegant way to solve this?
Sorry for trying to "outsource" this info, I haven't come up with any solution for this usecase yet...
I really appreciate your help and the value you create with tutorials like these! Keep it up :)
Thanks for the kind words! Personally I think saving images to a database is a bad idea. You want to save the image on disk and then save the path to it in the database. If you really want to do it, I guess you'll have to convert it to a Base64 string
@@jfversluis Wow that was a quick reply!
Yes, that's exactly what I was planning all along. I just had trouble finding a way to convert the StreamImageSource to a string.
I haven't found any suitable methods in the StreamImageSource object to do so. Converting a FileImageSource to string seems much simpler in contrast.
I'll try some more with Base64 string then.
Thanks!
Thank you so much for these most important things
Thank you Dipak!
How do I save the Image to my local storage?
What do you want to do with it?
@@jfversluis , it is also my goal, therefore this is my reply: I need to use the image as a "profile image", so I would like to store it somewhere (and somehow) in order to load and show everytime my Xamarin App is opened...
But this is the point of view and the strategy that i am thinking about, maybe there are better ones.
Thanks in advance
My Mediapicker doesn't save videos, could you give advice? I didn't receive any errors
Maybe check if you got the right permissions set up?
@@jfversluis it asks for permissions, it also capture video, and when i press ok, video dissappears from files.
@@jfversluis my manifest
My video code
private async Task AttachVideoMethodAsync()
{
var file = await MediaPicker.CaptureVideoAsync();
if (file == null)
{
await alertService.ShowMessage("Error", "Something wrong 0_o");
}
else
{
UploadedFile = await AttachFile();
await UploadPhotoToServer(UploadedFile, "file");
}
}
file has way to video , but video doesn't exist
Damn this is is a great tutorial, got it working in my app, thank u man god bless 🥺🙏
Wow thanks PJ! Glad it was helpful!
Permission are denied ,it's goes for camera?
Probably because you can also capture an image it also needs the camera permission
Thanks but please tell me abou some free reporting services in xamarin.forms and also told me how to generate PDF file from a collection view data .
I think that is nearly impossible for free since that are very extensive tools. Are you aware that SuncFusion offers community licenses which are free if you’re a small developer? I think they have some controls that might be what you’re looking for :)
@@jfversluis Thanks for reply. can we make pdf with WebView control in Xamarin, or can you please make a tutorial on it title: Make pdf of html page using WebView in Xamarin.Forms. i have follow different documentations for this purpose but nothing done.
@@jfversluis else please make a series or a single tutorial with Syncfusion controls for reporting. Thank you so much.
AMIR KHAN did you see this one? www.pujolsluis.com/how-to-display-pdf-in-xamarin-forms-with-ease/
AMIR KHAN I was just thinking about that :)
Hi,
The example is very good for image capture and display, but not for video, because it cannot be displayed.
Can you show me an example?
Why not for video?
async void Button1_Clicked(System.Object sender, System.EventArgs e)
{
var result = await MediaPicker.CaptureVideoAsync();
if (result != null)
{
var stream = await result.OpenReadAsync();
resultImage.Source = ImageSource.FromStream(() => stream);
}
}
The Android device does not display it.
Can you help me?
Hi, Does it supports allow cropping feature
I don’t think it does
@@jfversluis Thanks for the quick Reply 😊
Is there an option to pick videos AND photos from gallery using a single dialog?
I don't think that is possible right now
Thank you very much Gerald, you saved me. I SMASHED that big red beautiful subscribe button. Now I also ran into a little snag, the image I capture is not automatically saved, no errors shown, just doesn't save it, what do you suspect could be the issue?
Thanks! Appreciate it! There is no issue, I think this doesn’t save it automatically :) so either save it somewhere yourself, or if you want to save it to the gallery you might want to check this one: ua-cam.com/video/8JvgnlHVyrI/v-deo.html
Great video! Thanks dude
Great! Thanks for letting me know :)
Hello, Sorry but I keep getting this error when running the code, and I can't seem to find a solution:
'Method not found: bool Xamarin.Forms.Internals.ResourceLoader.get_IsEnabled()'
Make sure all your projects have the same versions of the nuget packages installed. This error message usually means that you haven’t :)
@@jfversluis Hello yea, I think the problem was that I needed to ensure I was using Version 10 of Android or something... I don't really know to be honest I just changed the version to 10 and removed the NuGet packages and them re-built the solution and like magic it worked! Thanks for the Video it was Great :D
Thank you! 🙏 glad you figured it out!
Great video, but unfortunately the app crashes after selecting the picture ...
Do you have any error message?
@@jfversluis no
@@JoJo-yu7hh there is probably something in the application output :) without any error message or info it’s hard to say
@@jfversluis The console outputs that: Java.IO.IOException: Failed to copy the given amount of bytes from the inputstream to the output stream.
Great tutorial!
Thank you so much!
Can pickup multiple images?
I don’t think that’s supported right now, sorry
@@jfversluis thanks for quick response.😊
very cool and perfect explained. thank you very much :)
Thanks Markus! Appreciate it!
Greetings to you !!!
Your Channel is a best
Thank you Muhammad! Appreciate it!
how to take multiphots without loop?
Can’t do it right now without a loop
Very helpful video, but i'm having an error.
whenever I press the button to pick a photo, i get an error.
System.TypeLoadException: 'Could not load type of field 'IMS.Returns.frmTakePhoto+d__1:5__2' (6) due to: Could not resolve type with token 010000a3 from typeref (expected class 'Xamarin.Essentials.FileResult' in assembly 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Xamarin.Essentials.FileResult member:(null)'
I tried googling it, but I got nothing I understood.
Thanks!
This usually happens when the versions on the different projects don’t line up. Please check if you have the same version of Essentials installed on your shared project as well as your platform projects
How to get and delete picture in xamarin forms
Don’t think that’s possible
@@jfversluis Why not possible?, could you help me, i want to get picture list and delete it, how to do it?
@@dotnettohard ah I think I misunderstood. It would be possible, but I don’t know if any library that does that right now so you would have to write platform code for that
@@jfversluis yes, my app would take many picture and only keep last picture for some bussiness. So i want to get and delete another it
Good to see your videos.
Good to see you’re watching them Rajesh! I hope you like them!
How to compress the image without saving to Mobile storage?
Compress without saving it to disk first? Or? Not sure what you mean :)
@@jfversluis when I capture an image using camera the compression ratio should be 40% . is there any possibility to do this using Xamarin essentials ? This image should not be stored in the users mobile storage.
I don’t think that’s in there yet. If you need it you probably want to use the media picker plug-in for now
@@jfversluis Thanks for the info, I will check with media picker.
I get a null ref exception on my android 10 oneplus 5t after clicking the check icon to confirm the image i took
Sorry to hear that! :( Looks like this issue is reported here: github.com/xamarin/Essentials/issues/1481
Make sure to add to that with all the details you can find!
@@jfversluis getting the same error... went ahead and added a post to the comments of the bug thread :(
Thanks for this video Your Videos Is Very Help Full for me Sir this is Working Fine In my Emulator and capture Image nd save local storage But Not Working on my Android real device should be work in my device?
You are most welcome! Is this with the demo code from the sample? And only on a real device?
@@jfversluis so how to work in my android Phone this sample code? plz help
I want to help you, but then I will need some information and answers to the questions I’m asking :)
@@jfversluis sure
yes plz
So, are you using the sample app that I use in the video? What device are you testing on?
1 sad thing about this Xamarin Essentials MediaPicker is, it does NOT have the most required CROP function!
It is indeed a work in progress. I wouldn't call it sad... See it as an opportunity to contribute ;)
Ha yes thank you for your good tutorial ❤️❤️
Thanks for watching!
Thank you so much.
Thanks Ranjit! It's my pleasure, glad it was useful :)
In android debug mode works perfectly but when is in release mode and then Archive to create the apk, give me this error:
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Xamarin.Essentials.FileResult' (defined in assembly , Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Xamarin.Essentials.FileResult
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
Hm looks like something with the linker settings... have a look at the repo issues if maybe someone encountered this
@@jfversluis I just resolved deteting the folder bin and obj of xamarin form, android and ios project.
Great! Glad you found the issue. Deleting bin/obj is like rebooting your machine 😂
@@jfversluis 😅🤣
like this after a picture is taken and accepted, xamarin essentials throws a nullreferenceexception
I had the same problem
Sorry for the late reply friends... Did you figure it out?
Thank you very much
Always a pleasure! I hope you find it useful
github.com/jfversluis/XFEMediaPickerSample
this sample code error (Take Image).
"System.NullReferenceException: Object reference not set to an instance of an object."
On what line exactly? What platform? Did you set the right permissions?
@@jfversluis samsung galaxy20.
camera permission ok.
i guess essential error.
On what line of code are you getting the error?
thank u bro...
You're welcome!