2 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 0
4 star 0
3 star 2
2 star 0
1 star 0
Compatible with
  • Android
  • iOS

XM.Media 1.0.3

xamarians

PCL library to click pictures using camera, pick media files(photo, video and audio) from gallery

Media

Cross platform library to click pictures using camera, pick media files(photo, video and audio) from gallery

First add component from xamarin component.

You can integrate media tools in Xamarin Form application using following code:

Shared Code -

Camera:-

using Xamarians.Media;

...
private string GenerateFilePath()
{
   return Path.Combine(MediaService.Instance.GetPublicDirectoryPath(), MediaService.Instance.GenerateUniqueFileName("jpg"));
}

string filePath = GenerateFilePath();
var result = await MediaService.Instance.TakePhotoAsync(new CameraOption()
{
  FilePath = filePath,
  MaxWidth = 300,
  MaxHeight = 300
});

Photo Picker:-

using Xamarians.Media;

...

var result = await MediaService.Instance.OpenMediaPickerAsync(MediaType.Image);

Video Picker:-

using Xamarians.Media;

...

var result = await MediaService.Instance.OpenMediaPickerAsync(MediaType.Video);

Audio Picker:-

using Xamarians.Media;

...

var result = await MediaService.Instance.OpenMediaPickerAsync(MediaType.Audio);

Resize Image:-

using Xamarians.Media;

...
private string GenerateFilePath()
{
   return Path.Combine(MediaService.Instance.GetPublicDirectoryPath(), MediaService.Instance.GenerateUniqueFileName("jpg"));
}

var result = await MediaService.Instance.OpenMediaPickerAsync(MediaType.Image);
string resizeFilePath = GenerateFilePath();
var success = await MediaService.Instance.ResizeImageAsync(result.FilePath, resizeFilePath, 250, 250);

Android - in MainActivity file write below code -

Xamarians.Media.Droid.MediaServiceAndroid.Initialize();  

iOS - in AppDelegate file write below code -

Xamarians.Media.iOS.MediaServiceIOS.Initialize();  

The following permissions are needed in iOS -

NSCameraUsageDescription    
NSPhotoLibraryUsageDescription
NSMicrophoneUsageDescription
TCCServiceMediaLibrary
NSAppleMusicUsageDescription

Release Notes

Bug fixes

Write a Review

1 review

Adewale Adetoye rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

There seems to be no way to get stream object or byte[] from the pictures taken?

Posted on: October 13, 2017 / Version: 1.0.3