Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to access video from gallery in monotouch?

rzee7rzee7 INUniversity ✭✭✭✭✭

I Am working on mono as new developer!

I am facing a problem with Upload Video on Azure Through WCF Service! I am able to go on Gallery in IOs Simulator 6.0 (Newly Updated) But While I am choose video Its just showing video compressing thats it! until closed the application! Here is my code Please take a look and help me!

thank you so much in advance.;

partial void TakeMediaClick (NSObject sender)

{

UIImagePickerController imageController = new UIImagePickerController();

    byte[] buffer=null;
    imageController.SourceType= UIImagePickerControllerSourceType.SavedPhotosAlbum;
    imageController.MediaTypes=new string[]{"public.movie"};
    NavigationController.PresentViewController(imageController, true, null);
    imageController.FinishedPickingMedia += (object sender1, UIImagePickerMediaPickedEventArgs e) => {
        BeginInvokeOnMainThread (delegate {
            imageController.DismissViewController(false, null);
            NavigationController.DismissViewController(false, null);
            NSUrl mediaURL = e.MediaUrl;
            NSData data = NSData.FromUrl (mediaURL);
            buffer = new byte[data.Length];
            System.Runtime.InteropServices.Marshal.Copy (data.Bytes, buffer, 0, Convert.ToInt32 (data.Length));
        });                         
    };
    string VideoContents = Convert.ToBase64String (buffer);
    ServiceFacade.GetBindingClient ().UploadOnGalleryAsync (VideoContents, MediaType.Text+".m4v", MediaName.Text + ".m4v", MediaDescription.Text, AssocitaionID);
    ServiceFacade.GetBindingClient ().UploadOnGalleryCompleted += (object sender1, UploadOnGalleryCompletedEventArgs e1) =>{
        if (e1.Result == 1) 
        {
            InvokeOnMainThread (delegate 
                                {
                MediaName.Text = string.Empty;
                MediaDescription.Text = string.Empty;
                MediaType.Text = "Select";
                var alert = new UIAlertView ("Media Uploaded", "Media File Uploaded Successfully", null, "Ok");
                alert.Show ();
            } );
        }
    }; 

}

Posts

  • prashantvcprashantvc USXamarin Team Xamurai

    Hi @Rzee

    Are you sure you don't get any exception in the code, I believe when control reaches this line
    the buffer will still be null!

      string VideoContents = Convert.ToBase64String (buffer);
    

    Please post if there are any error messages or information in the MonoDevelop output window, it helps us resolve the issue

Sign In or Register to comment.