UNPKG

@capacitor-community/media

Version:

Capacitor plugin for saving and retrieving photos and videos, and managing photo albums.

597 lines 17.7 kB
{ "api": { "name": "MediaPlugin", "slug": "mediaplugin", "docs": "", "tags": [], "methods": [ { "name": "getMedias", "signature": "(options?: MediaFetchOptions | undefined) => Promise<MediaResponse>", "parameters": [ { "name": "options", "docs": "", "type": "MediaFetchOptions | undefined" } ], "returns": "Promise<MediaResponse>", "tags": [], "docs": "Get filtered thumbnails from camera roll. iOS only.\n\n[Code Examples](https://github.com/capacitor-community/media/blob/main/example/src/components/GetMedias.tsx)", "complexTypes": [ "MediaResponse", "MediaFetchOptions" ], "slug": "getmedias" }, { "name": "getMediaByIdentifier", "signature": "(options?: { identifier: string; } | undefined) => Promise<MediaPath>", "parameters": [ { "name": "options", "docs": "", "type": "{ identifier: string; } | undefined" } ], "returns": "Promise<MediaPath>", "tags": [], "docs": "Get a filesystem path to a full-quality media asset by its identifier. iOS only.\nThis is not included for Android because on Android, a media asset's identifier IS its path!\nYou can simply use the Filesystem plugin to work with it. On iOS, you have to turn the identifier into a path\nusing this function. After that, you can use the Filesystem plugin, same as Android.\n\n[Code Examples](https://github.com/capacitor-community/media/blob/main/example/src/components/GetMedias.tsx)", "complexTypes": [ "MediaPath" ], "slug": "getmediabyidentifier" }, { "name": "getAlbums", "signature": "() => Promise<MediaAlbumResponse>", "parameters": [], "returns": "Promise<MediaAlbumResponse>", "tags": [], "docs": "Get list of albums.\n\n[Code Examples](https://github.com/capacitor-community/media/blob/main/example/src/components/GetAlbums.tsx)", "complexTypes": [ "MediaAlbumResponse" ], "slug": "getalbums" }, { "name": "savePhoto", "signature": "(options?: MediaSaveOptions | undefined) => Promise<PhotoResponse>", "parameters": [ { "name": "options", "docs": "", "type": "MediaSaveOptions | undefined" } ], "returns": "Promise<PhotoResponse>", "tags": [], "docs": "Saves a still photo or GIF to the camera roll.\n\nOn Android and iOS, this supports web URLs, base64 encoded images\n(e.g. data:image/jpeg;base64,...), and local files.\nOn Android, all image formats supported by the user's photo viewer are supported.\nOn iOS, most common image formats are supported.\n\n[Code Examples](https://github.com/capacitor-community/media/blob/main/example/src/components/SaveMedia.tsx)", "complexTypes": [ "PhotoResponse", "MediaSaveOptions" ], "slug": "savephoto" }, { "name": "saveVideo", "signature": "(options?: MediaSaveOptions | undefined) => Promise<PhotoResponse>", "parameters": [ { "name": "options", "docs": "", "type": "MediaSaveOptions | undefined" } ], "returns": "Promise<PhotoResponse>", "tags": [], "docs": "Saves a video to the camera roll.\n\nOn Android and iOS, this supports web URLs, base64 encoded videos\n(e.g. data:image/mp4;base64,...), and local files.\nOn Android, all video formats supported by the user's photo viewer are supported.\nOn iOS, the supported formats are based on whatever iOS supports at the time.\n\n[Code Examples](https://github.com/capacitor-community/media/blob/main/example/src/components/SaveMedia.tsx)", "complexTypes": [ "PhotoResponse", "MediaSaveOptions" ], "slug": "savevideo" }, { "name": "createAlbum", "signature": "(options: MediaAlbumCreate) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "MediaAlbumCreate" } ], "returns": "Promise<void>", "tags": [], "docs": "Creates an album.\n\n[Code Examples](https://github.com/capacitor-community/media/blob/main/example/src/components/CreateDemoAlbum.tsx)", "complexTypes": [ "MediaAlbumCreate" ], "slug": "createalbum" }, { "name": "getAlbumsPath", "signature": "() => Promise<AlbumsPathResponse>", "parameters": [], "returns": "Promise<AlbumsPathResponse>", "tags": [], "docs": "Gets the path where album folders and their corresponding photos\nare stored on the Android filesystem. This can be used to identify\nyour album by more than just its name on Android, in case there\nare multiple albums with the same name, which is possible on Android.\nJust compare the albums path to the start of the album identifier when\ngetting albums.\n\nOnly available on Android.\n\nCode Examples: [basic](https://github.com/capacitor-community/media/blob/main/example/src/components/CreateDemoAlbum.tsx), [when saving media](https://github.com/capacitor-community/media/blob/main/example/src/components/SaveMedia.tsx)", "complexTypes": [ "AlbumsPathResponse" ], "slug": "getalbumspath" } ], "properties": [] }, "interfaces": [ { "name": "MediaResponse", "slug": "mediaresponse", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "medias", "tags": [], "docs": "", "complexTypes": [ "MediaAsset" ], "type": "MediaAsset[]" } ] }, { "name": "MediaAsset", "slug": "mediaasset", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "identifier", "tags": [], "docs": "Platform-specific identifier", "complexTypes": [], "type": "string" }, { "name": "data", "tags": [], "docs": "Data for a photo asset as a base64 encoded string (JPEG only supported)", "complexTypes": [], "type": "string" }, { "name": "creationDate", "tags": [], "docs": "ISO date string for creation date of asset", "complexTypes": [], "type": "string" }, { "name": "duration", "tags": [], "docs": "Duration of asset in seconds, only returned for videos", "complexTypes": [], "type": "number | undefined" }, { "name": "fullWidth", "tags": [], "docs": "Full width of original asset", "complexTypes": [], "type": "number" }, { "name": "fullHeight", "tags": [], "docs": "Full height of original asset", "complexTypes": [], "type": "number" }, { "name": "thumbnailWidth", "tags": [], "docs": "Width of thumbnail preview", "complexTypes": [], "type": "number" }, { "name": "thumbnailHeight", "tags": [], "docs": "Height of thumbnail preview", "complexTypes": [], "type": "number" }, { "name": "location", "tags": [], "docs": "Location metadata for the asset", "complexTypes": [ "MediaLocation" ], "type": "MediaLocation" } ] }, { "name": "MediaLocation", "slug": "medialocation", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "latitude", "tags": [], "docs": "GPS latitude image was taken at", "complexTypes": [], "type": "number" }, { "name": "longitude", "tags": [], "docs": "GPS longitude image was taken at", "complexTypes": [], "type": "number" }, { "name": "heading", "tags": [], "docs": "Heading of user at time image was taken", "complexTypes": [], "type": "number" }, { "name": "altitude", "tags": [], "docs": "Altitude of user at time image was taken", "complexTypes": [], "type": "number" }, { "name": "speed", "tags": [], "docs": "Speed of user at time image was taken", "complexTypes": [], "type": "number" } ] }, { "name": "MediaFetchOptions", "slug": "mediafetchoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "quantity", "tags": [], "docs": "The number of photos to fetch, sorted by last created date descending. To paginate, just request a higher quantity -- OS caching should make this relatively performant.", "complexTypes": [], "type": "number | undefined" }, { "name": "thumbnailWidth", "tags": [], "docs": "The width of thumbnail to return", "complexTypes": [], "type": "number | undefined" }, { "name": "thumbnailHeight", "tags": [], "docs": "The height of thumbnail to return", "complexTypes": [], "type": "number | undefined" }, { "name": "thumbnailQuality", "tags": [], "docs": "The quality of thumbnail to return as JPEG (0-100)", "complexTypes": [], "type": "number | undefined" }, { "name": "types", "tags": [], "docs": "Which types of assets to return thumbnails for.", "complexTypes": [], "type": "'photos' | 'videos' | 'all' | undefined" }, { "name": "albumIdentifier", "tags": [], "docs": "Which album identifier to query in (get identifier with getAlbums())", "complexTypes": [], "type": "string | undefined" }, { "name": "sort", "tags": [], "docs": "Sort order of returned assets by field and ascending/descending", "complexTypes": [ "MediaField", "MediaSort" ], "type": "MediaField | MediaSort[] | undefined" } ] }, { "name": "MediaSort", "slug": "mediasort", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "key", "tags": [], "docs": "", "complexTypes": [ "MediaField" ], "type": "MediaField" }, { "name": "ascending", "tags": [], "docs": "", "complexTypes": [], "type": "boolean" } ] }, { "name": "MediaPath", "slug": "mediapath", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "path", "tags": [], "docs": "Path to media asset", "complexTypes": [], "type": "string" }, { "name": "identifier", "tags": [], "docs": "Identifier for media asset", "complexTypes": [], "type": "string" } ] }, { "name": "MediaAlbumResponse", "slug": "mediaalbumresponse", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "albums", "tags": [], "docs": "", "complexTypes": [ "MediaAlbum" ], "type": "MediaAlbum[]" } ] }, { "name": "MediaAlbum", "slug": "mediaalbum", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "identifier", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "name", "tags": [], "docs": "", "complexTypes": [], "type": "string" }, { "name": "type", "tags": [], "docs": "", "complexTypes": [ "MediaAlbumType" ], "type": "MediaAlbumType" } ] }, { "name": "PhotoResponse", "slug": "photoresponse", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "filePath", "tags": [], "docs": "Available on Android only.", "complexTypes": [], "type": "string | undefined" }, { "name": "identifier", "tags": [], "docs": "Available on iOS only. To get a file path\nfor an image on iOS, pass this identifier to\n`getMediaByIdentifier`.", "complexTypes": [], "type": "string | undefined" } ] }, { "name": "MediaSaveOptions", "slug": "mediasaveoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "path", "tags": [], "docs": "Web URL, base64 encoded URI, or local file path to save.", "complexTypes": [], "type": "string" }, { "name": "albumIdentifier", "tags": [], "docs": "Album identifier from getAlbums().\nSince 5.0, identifier is used on both Android and iOS.\nIdentifier is required on Android but not on iOS.\nOn iOS 14+, if the identifier is not specified and no permissions\nhave been requested yet, add-only permissions will be requested instead\nof full permissions (assuming NSPhotoLibraryAddUsageDescription\nis in Info.plist).", "complexTypes": [], "type": "string | undefined" }, { "name": "fileName", "tags": [], "docs": "File name to save the image as in the album.\nDo not include extension. Android only.", "complexTypes": [], "type": "string | undefined" } ] }, { "name": "MediaAlbumCreate", "slug": "mediaalbumcreate", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "name", "tags": [], "docs": "", "complexTypes": [], "type": "string" } ] }, { "name": "AlbumsPathResponse", "slug": "albumspathresponse", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "path", "tags": [], "docs": "", "complexTypes": [], "type": "string" } ] } ], "enums": [ { "name": "MediaAlbumType", "slug": "mediaalbumtype", "members": [ { "name": "Smart", "value": "'smart'", "tags": [], "docs": "Album is a \"smart\" album (such as Favorites or Recently Added)" }, { "name": "Shared", "value": "'shared'", "tags": [], "docs": "Album is a cloud-shared album" }, { "name": "User", "value": "'user'", "tags": [], "docs": "Album is a user-created album" } ] } ], "typeAliases": [ { "name": "MediaField", "slug": "mediafield", "docs": "Attributes to sort media by.\n\n[iOS Source](https://developer.apple.com/documentation/photokit/phfetchoptions)", "types": [ { "text": "'mediaType'", "complexTypes": [] }, { "text": "'mediaSubtypes'", "complexTypes": [] }, { "text": "'sourceType'", "complexTypes": [] }, { "text": "'pixelWidth'", "complexTypes": [] }, { "text": "'pixelHeight'", "complexTypes": [] }, { "text": "'creationDate'", "complexTypes": [] }, { "text": "'modificationDate'", "complexTypes": [] }, { "text": "'isFavorite'", "complexTypes": [] }, { "text": "'burstIdentifier'", "complexTypes": [] } ] } ], "pluginConfigs": [ { "name": "Media", "slug": "media", "properties": [ { "name": "androidGalleryMode", "tags": [], "docs": "Enable gallery mode on Android. This is for photo gallery-style apps, which\nneed to access images from all apps on the device. Most use cases will not\nneed this. Defaults to false.\n\nIf you enable this, you will also need to add the\nREAD_MEDIA_IMAGES, READ_MEDIA_VIDEOS,\nREAD_EXTERNAL_STORAGE, and WRITE_EXTERNAL_STORAGE\npermissions to your AndroidManifest.xml.", "complexTypes": [], "type": "boolean | undefined" } ], "docs": "" } ] }