6.0.1 • Published 19 days ago

@whiteguru/capacitor-plugin-media v6.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
19 days ago

@whiteguru/capacitor-plugin-media

Capacitor plugin to handle media files

Install (Capacitor 6.x)

npm install @whiteguru/capacitor-plugin-media
npx cap sync

or for Capacitor 5.x

npm install @whiteguru/capacitor-plugin-media@^5.0.2
npx cap sync

or for Capacitor 4.x

npm install @whiteguru/capacitor-plugin-media@^4.1.1
npx cap sync

or for Capacitor 3.x

npm install @whiteguru/capacitor-plugin-media@^3.0.1
npx cap sync

Android

This API requires the following permissions be added to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

Read about Setting Permissions in the Android Guide for more information on setting Android permissions.

API

getMedias(...)

getMedias(options?: MediaFetchOptions | undefined) => Promise<MediasResponse>

Get list of user medias. IOS only

ParamType
optionsMediaFetchOptions

Returns: Promise<MediasResponse>


getAlbums()

getAlbums() => Promise<MediaAlbumResponse>

Get list of user albums. IOS and Android Api 29+

Returns: Promise<MediaAlbumResponse>


savePhoto(...)

savePhoto(options?: MediaSaveOptions | undefined) => Promise<MediaResponse>

Add image to gallery. Creates album if not exists.

ParamType
optionsMediaSaveOptions

Returns: Promise<MediaResponse>


saveVideo(...)

saveVideo(options?: MediaSaveOptions | undefined) => Promise<MediaResponse>

Add video to gallery. Creates album if not exists.

ParamType
optionsMediaSaveOptions

Returns: Promise<MediaResponse>


saveGif(...)

saveGif(options?: MediaSaveOptions | undefined) => Promise<MediaResponse>

Add gif to gallery. Creates album if not exists.

ParamType
optionsMediaSaveOptions

Returns: Promise<MediaResponse>


saveDocument(...)

saveDocument(options?: MediaSaveOptions | undefined) => Promise<MediaResponse>

Add document to gallery. Android only. Create album if not exists.

ParamType
optionsMediaSaveOptions

Returns: Promise<MediaResponse>


saveAudio(...)

saveAudio(options?: MediaSaveOptions | undefined) => Promise<MediaResponse>

Add audio to gallery. Android only. Creates album if not exists.

ParamType
optionsMediaSaveOptions

Returns: Promise<MediaResponse>


createAlbum(...)

createAlbum(options: MediaAlbumCreate) => Promise<MediaAlbum>

Create album. IOS only

ParamType
optionsMediaAlbumCreate

Returns: Promise<MediaAlbum>


Interfaces

MediasResponse

PropType
mediasMediaAsset[]

MediaAsset

PropTypeDescription
identifierstringPlatform-specific identifier
datastringData for a photo asset as a base64 encoded string (JPEG only supported)
creationDatestringISO date string for creation date of asset
fullWidthnumberFull width of original asset
fullHeightnumberFull height of original asset
thumbnailWidthnumberWidth of thumbnail preview
thumbnailHeightnumberHeight of thumbnail preview
locationMediaLocationLocation metadata for the asset

MediaLocation

PropTypeDescription
latitudenumberGPS latitude image was taken at
longitudenumberGPS longitude image was taken at
headingnumberHeading of user at time image was taken
altitudenumberAltitude of user at time image was taken
speednumberSpeed of user at time image was taken

MediaFetchOptions

PropTypeDescription
quantitynumberThe number of photos to fetch, sorted by last created date descending
thumbnailWidthnumberThe width of thumbnail to return
thumbnailHeightnumberThe height of thumbnail to return
thumbnailQualitynumberThe quality of thumbnail to return as JPEG (0-100)
typesstringWhich types of assets to return (currently only supports "photos")
albumIdentifierstringWhich album identifier to query in (get identifier with getAlbums())

MediaAlbumResponse

PropTypeDescription
albumsMediaAlbum[]Array of MediaAlbum

MediaAlbum

PropTypeDescription
identifierstringPlatform-specific album identifier
namestringAlbum name
typeMediaAlbumTypeAlbum type

MediaResponse

PropTypeDescription
pathstringMedia path
namestringMedia name

MediaSaveOptions

PropTypeDescription
pathstringPath of file to add
album{ id?: string; name?: string; }Album to add media. If no 'id' and 'name' not exists, album 'name' will be created.

MediaAlbumCreate

PropTypeDescription
namestringAlbum name

Enums

MediaAlbumType

MembersValueDescription
Smart'smart'Album is a "smart" album (such as Favorites or Recently Added)
Shared'shared'Album is a cloud-shared album
User'user'Album is a user-created album
6.0.1

19 days ago

5.0.2

8 months ago

5.0.1

1 year ago

5.0.1-0

1 year ago

3.0.1

2 years ago

1.2.3

2 years ago

4.1.0

1 year ago

4.0.1

2 years ago

4.1.1

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago