Usage

Media Services allows camera capture, gallery selection, and image saving on mobile devices

Essential Kit wraps native iOS and Android media APIs into a single Unity interface. All media operations automatically handle permissions - the first call triggers the system permission dialog if needed.

Table of Contents

Understanding Core Concepts

Media Content Types

Media Services supports three content types through unified APIs:

  • Images: PNG, JPEG photos from gallery or camera

  • Videos: MP4, MOV videos from gallery or camera

  • Documents: PDFs and other file types (gallery selection only)

Permission Modes

Gallery access has different permission levels:

  • Read: Select existing media from gallery

  • Write: Save new media to gallery

  • Add: Add media without full gallery access (iOS 14+ limited library)

IMediaContent Interface

All media operations return IMediaContent instances that can be converted to:

  • Texture2D: For displaying images in UI

  • File Path: For saving to disk with custom location

  • Raw Data: For uploading to servers or custom processing

Import Namespaces

How Permissions Work

Just call the media operation directly - no permission checks needed. Essential Kit automatically shows the system permission dialog on first use. If permission is granted, the operation executes. If denied, the error callback explains why.

Handle permission issues in the error callback:

Optional: Check Permission Status

Use GetGalleryAccessStatus() or GetCameraAccessStatus() only when you need to inspect the exact state before calling the main operation or to customize UI messaging.

Let players choose existing media from their device for avatars, backgrounds, or user-generated content features without requiring them to take new photos.

This ensures:

  • Faster user onboarding (use existing photos)

  • Privacy-friendly selection (Photo Picker on modern platforms)

  • Multiple file type support (images, videos, documents)

Basic Image Selection

Multiple Selection

Selecting Videos

Custom MIME Type Selection

Capturing Media with Camera

Why Camera Capture is Needed

Let players create new content directly from your app - profile photos, in-game screenshots with real backgrounds, or user-generated content.

This ensures:

  • Fresh, context-appropriate content creation

  • Immediate photo/video capture without leaving the app

  • Native camera interface with platform-optimized controls

Capturing a Photo

Capturing a Video

Advanced Capture Options

Why Saving Media is Needed

Let players save game screenshots, generated images, or downloaded content to their device for sharing and keeping.

This ensures:

  • Players can share achievements on social media

  • Generated content persists outside the app

  • Screenshots can be accessed from native photo apps

Saving a Screenshot

Saving Without Custom Album

Working with IMediaContent

IMediaContent is the universal interface for all media returned by Essential Kit. It supports three conversion methods:

Convert to Texture2D

Convert to File Path

Get Raw Media Data

Data Properties

Item
Type
Notes

IMediaContent

Interface

Provides asynchronous helpers (AsTexture2D, AsFilePath, AsRawMediaData) so you can retrieve the captured or selected asset in the format your UI or backend expects.

RawMediaData.Bytes

byte[]

Raw payload returned by AsRawMediaData; combine with RawMediaData.Mime to upload files or persist binary data accurately.

RawMediaData.Mime

string

MIME type that Essential Kit detected for the media item (image/png, video/mp4, etc.); use it when saving or posting to remote services.

MediaServicesErrorCode

Enum

Values surfaced through Error.Code inside callbacks. Use it to branch on permission issues, cancellations, or platform errors before retrying.

Core APIs Reference

API
Purpose
Returns

MediaServices.SelectMediaContent(options, callback)

Open gallery to select media

IMediaContent[] via callback

MediaServices.CaptureMediaContent(options, callback)

Open camera to capture photo/video

IMediaContent via callback

MediaServices.SaveMediaContent(data, mimeType, options, callback)

Save media to device gallery

bool success via callback

MediaContentSelectOptions.CreateForImage()

Create selection options for images

MediaContentSelectOptions

MediaContentSelectOptions.CreateForVideo()

Create selection options for videos

MediaContentSelectOptions

MediaContentCaptureOptions.CreateForImage()

Create capture options for photos

MediaContentCaptureOptions

MediaContentCaptureOptions.CreateForVideo()

Create capture options for videos

MediaContentCaptureOptions

MediaServices.GetGalleryAccessStatus(mode)

Optional: Check gallery permission

GalleryAccessStatus enum

MediaServices.GetCameraAccessStatus()

Optional: Check camera permission

CameraAccessStatus enum

Error Handling

Error Code
Trigger
Recommended Action

PermissionNotAvailable

User declined camera/gallery access

Show rationale + link to Utilities.OpenApplicationSettings()

UserCancelled

User closed picker/camera without selecting

Log for analytics, no error message needed

Unknown

Platform error during operation

Retry or log for support investigation

DataNotAvailable

Missing required data in the underlying service

Validate options before calling API

Advanced: Manual Initialization

Understanding Manual Initialization

Default Behavior: Essential Kit automatically initializes Media Services using settings from the ScriptableObject configured in the Unity Editor.

Advanced Usage: Override default settings at runtime when you need:

  • Feature flags based on user subscription level

  • A/B testing different camera quality settings

  • Server-driven feature configuration

  • Dynamic album names based on game state

Implementation

Override settings at runtime before using Media Services:

Call Initialize() before any media operations. Most games should use the standard setup configured in Essential Kit Settings instead.

  • Demo scene: Assets/Plugins/VoxelBusters/EssentialKit/Examples/Scenes/MediaServicesDemo.unity

  • Pair with Sharing Services to share selected images via native share sheet

  • Use with Utilities.OpenApplicationSettings() for permission recovery flows

  • See Testing Guide for editor simulation and device validation

Last updated

Was this helpful?