locked
How to take multiple pictures using camera in xamarin IOS? RRS feed

  • Question

  • User251528 posted

    i am using xamarin forms. In android i used intent for taking multiple pictures. But in IOS i know how to take single image in one click. I want to know how to implement multiple image capture using camera in IOS.

    Friday, September 29, 2017 8:24 AM

Answers

  • User171749 posted

    @rakeshraghavan said: As you told i repeated the code in loop .But suppose if user only want 2 images? for (int i = 0; i < 3; i++) {

                                file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
                                if (file != null)
    

    { //code to save }

    The user can press cancel at anytime to stop taking pictures, and it'll hit the return and stop running the code. But its ran the logic to save the images each time a photo has been taken.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, October 5, 2017 7:17 AM
  • User251528 posted

    @seanyda Thanks a lot.

    I added a infinite loop .i user press back button in android and user click cancel in ios the loop will exit

    bool isCamera = true; while (isCamera) { file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" }); if (file != null) { //save code} else{ isCamera=false; }

    }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, October 6, 2017 5:09 AM

All replies

  • User171749 posted

    I might be wrong but I believe there are limitations on the iOS API preventing you taking multiple photos. The workaround I have is use the Xam.Plugin.Media plugin and once the image has been taken, fire the same call.

    It keeps looping through until the user presses cancel.

    var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
        {
            Directory = "Sample",
            Name = "test.jpg"
        });
    
        if (file == null)
            return;
    
        await DisplayAlert("File Location", file.Path, "OK");
    
        image.Source = ImageSource.FromStream(() =>
        {
            var stream = file.GetStream();
            file.Dispose();
            return stream;
        }); 
    
    RUNMETHODAGAIN();
    
    Friday, September 29, 2017 8:30 AM
  • User251528 posted

    @seanyda thank you for your reply. These code is for taking a single photo. But i need to open my camera and take multiple pictures at a time. In android i used MediaStore.INTENTACTIONSTILLIMAGECAMERA. But in IOS I dont have any idea

    Friday, September 29, 2017 8:37 AM
  • User171749 posted

    Yeah but what the code is doing is opening up the camera, Taking a photo, closing the camera and then instantly reopening it again. So you're taking multiple photos because it's rerunning the method without any more user input. It's not exactly what you're looking for but it's a workaround.

    Friday, September 29, 2017 8:42 AM
  • User251528 posted

    As you told i repeated the code in loop .But suppose if user only want 2 images? for (int i = 0; i < 3; i++) {

                                file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
                                if (file != null)
    

    { //code to save }

    Tuesday, October 3, 2017 10:10 AM
  • User251528 posted

    Is there any solution for my issue?

    Thursday, October 5, 2017 4:28 AM
  • User191123 posted

    @rakeshraghavan said: As you told i repeated the code in loop .But suppose if user only want 2 images? for (int i = 0; i < 3; i++) {

                                file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
                                if (file != null)
    

    { //code to save }

    Then create a user input letting the user decide how many pictures he wants to take?

    Thursday, October 5, 2017 6:55 AM
  • User171749 posted

    @rakeshraghavan said: As you told i repeated the code in loop .But suppose if user only want 2 images? for (int i = 0; i < 3; i++) {

                                file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
                                if (file != null)
    

    { //code to save }

    The user can press cancel at anytime to stop taking pictures, and it'll hit the return and stop running the code. But its ran the logic to save the images each time a photo has been taken.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, October 5, 2017 7:17 AM
  • User251528 posted

    @seanyda Thanks a lot.

    I added a infinite loop .i user press back button in android and user click cancel in ios the loop will exit

    bool isCamera = true; while (isCamera) { file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" }); if (file != null) { //save code} else{ isCamera=false; }

    }

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, October 6, 2017 5:09 AM
  • User59849 posted

    We had the same request several times in our app projects, therefore we started developing a plugin for that. You can try CrossApps.Photo.Plugin it allows you to take multiple images in one view, but is still beta -.-

    Monday, January 14, 2019 7:41 PM
  • User59849 posted

    We finished our beta test you can get a trial version on our web page, just google for xamarin forms photo plugin (cross-apps)

    Wednesday, June 12, 2019 1:43 PM