/Zebble.Media

A Zebble plugin for taking and picking photos and videos

Primary LanguageC#OtherNOASSERTION

Zebble.Media

logo

A plugin to use camera for capturing or picking photos or videos on Zebble applications.

NuGet


Setup


Api Usage

Call Zebble.Device.Media from any project to gain access to APIs.

Check device camera availabelity:
Device.Media.IsCameraAvailable();

Also, you can use SupportsTakingPhoto or SupportsTakingVideo methods to determine if taking photo or video is supported on the device.

//Photo
Device.Media.SupportsTakingPhoto();
//Video
Device.Media.SupportsTakingVideo();
Taking media:
//Photo
var photoFile = await Device.Media.TakePhoto(); 
//Video
var videoFile = await Device.Media.TakeVideo();

After the media is taken, it is returned as a temporary file which can be processed in your application. TakePhoto() or TakeVideo methods will internally check for camera availablity and support for photo or video taking and even request permission to use the camera. If there is any problem or if the user cancels the process, it will simply return Null.

Picking media:
//Photo
var photoFile = await Device.Media.PickPhoto(); 
//Video
var videoFile = await Device.Media.PickVideo();
Save a media to gallery:
Device.Media.SaveToAlbum(myfile);

Platform Specific Notes

Some platforms require some setting to make you able to use this plugin.

Android

if your target API is grater then 24 you should add these codes to the manifest file:

<application>
   ...
   <provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}.zebblefileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
      <meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/file_paths"/>
    </provider>
    ...
</application>

Then, create new file under res/xml/media_file_paths.xml and add below code to it.

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-files-path name="my_images" path="Pictures" />
    <external-files-path name="my_movies" path="Movies" />
</paths>

Methods

Method Return Type Parameters Android iOS Windows
IsCameraAvailable Task<bool> - x x x
SupportsTakingPhoto bool - x x x
SupportsTakingVideo bool - x x x
SupportsPickingPhoto bool - x x x
SupportsPickingVideo bool - x x x
TakePhoto Task<FileInfo> settings -> MediaCaptureSettings
errorAction -> OnError
x x x
TakeVideo Task<FileInfo> settings -> MediaCaptureSettings
errorAction -> OnError
x x x
PickPhoto Task<FileInfo> errorAction -> OnError x x x
PickVideo Task<FileInfo> errorAction -> OnError x x x
SaveToAlbum Task<bool> file -> FileInfo
errorAction -> OnError
x x x