npm package: @hanhokim/capacitor-device-media
Description: Device Media
Author: Hanho Kim
Latest version: 7.0.1

# @hanhokim/capacitor-device-media

Device medias from capacitor. For internal project usage

## Install

```bash
npm install @hanhokim/capacitor-device-media
npx cap sync
```

## API

<docgen-index>

* [`echo(...)`](#echo)
* [`getThumbnails(...)`](#getthumbnails)
* [`getMedia(...)`](#getmedia)
* [`getAlbums()`](#getalbums)
* [`addListener('mediaDidChanged', ...)`](#addlistenermediadidchanged-)
* [Interfaces](#interfaces)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### echo(...)

```typescript
echo(options: { value: string; }) => Promise<{ value: string; }>
```

| Param         | Type                            |
| ------------- | ------------------------------- |
| **`options`** | <code>{ value: string; }</code> |

**Returns:** <code>Promise&lt;{ value: string; }&gt;</code>

--------------------


### getThumbnails(...)

```typescript
getThumbnails(options?: ThumbnailFetchOptions | undefined) => Promise<ThumbnailResponse | undefined>
```

| Param         | Type                                                                    |
| ------------- | ----------------------------------------------------------------------- |
| **`options`** | <code><a href="#thumbnailfetchoptions">ThumbnailFetchOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#thumbnailresponse">ThumbnailResponse</a>&gt;</code>

--------------------


### getMedia(...)

```typescript
getMedia(options?: MediaFetchOptions | undefined) => Promise<MediaResponse | undefined>
```

| Param         | Type                                                            |
| ------------- | --------------------------------------------------------------- |
| **`options`** | <code><a href="#mediafetchoptions">MediaFetchOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#mediaresponse">MediaResponse</a>&gt;</code>

--------------------


### getAlbums()

```typescript
getAlbums() => Promise<MediaAlbumResponse | undefined>
```

**Returns:** <code>Promise&lt;<a href="#mediaalbumresponse">MediaAlbumResponse</a>&gt;</code>

--------------------


### addListener('mediaDidChanged', ...)

```typescript
addListener(eventName: 'mediaDidChanged', listenerFunc: (event: any) => void) => Promise<PluginListenerHandle>
```

| Param              | Type                                 |
| ------------------ | ------------------------------------ |
| **`eventName`**    | <code>'mediaDidChanged'</code>       |
| **`listenerFunc`** | <code>(event: any) =&gt; void</code> |

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

--------------------


### Interfaces


#### ThumbnailResponse

| Prop         | Type                      |
| ------------ | ------------------------- |
| **`medias`** | <code>MediaAsset[]</code> |


#### MediaAsset

| Prop                  | Type                                            | Description                                |
| --------------------- | ----------------------------------------------- | ------------------------------------------ |
| **`identifier`**      | <code>string</code>                             | Platform-specific identifier               |
| **`data`**            | <code><a href="#mediadata">MediaData</a></code> | Data for a media : url or base64           |
| **`mediaType`**       | <code>string</code>                             | Data for a mediaType : image or video      |
| **`mediaSubtype`**    | <code>string</code>                             | Data for a mediaSubtype such as png, mp4   |
| **`fileSize`**        | <code>number</code>                             | Data for a filesize as Byte                |
| **`creationDate`**    | <code>string</code>                             | ISO date string for creation date of asset |
| **`fullWidth`**       | <code>number</code>                             | Full width of original asset               |
| **`fullHeight`**      | <code>number</code>                             | Full height of original asset              |
| **`thumbnailWidth`**  | <code>number</code>                             | Width of thumbnail preview                 |
| **`thumbnailHeight`** | <code>number</code>                             | Height of thumbnail preview                |
| **`duration`**        | <code>any</code>                                | Duration of media                          |


#### MediaData

| Prop         | Type                |
| ------------ | ------------------- |
| **`base64`** | <code>string</code> |
| **`url`**    | <code>string</code> |


#### ThumbnailFetchOptions

| Prop                   | Type                | Description                                                           |
| ---------------------- | ------------------- | --------------------------------------------------------------------- |
| **`quantity`**         | <code>number</code> | The number of photos to fetch, sorted by last created date descending |
| **`thumbnailWidth`**   | <code>number</code> | The width of thumbnail to return                                      |
| **`thumbnailHeight`**  | <code>number</code> | The height of thumbnail to return                                     |
| **`thumbnailQuality`** | <code>number</code> | The quality of thumbnail to return as JPEG (0-100)                    |
| **`types`**            | <code>string</code> | Which types of assets to return (photos or videos or all)             |
| **`albumIdentifier`**  | <code>string</code> | Which album identifier to query in (get identifier with getAlbums())  |
| **`start`**            | <code>number</code> | The start index of photos to fetch (for pagination)                   |


#### MediaResponse

| Prop         | Type                      |
| ------------ | ------------------------- |
| **`medias`** | <code>MediaAsset[]</code> |


#### MediaFetchOptions

| Prop                  | Type                | Description                                      |
| --------------------- | ------------------- | ------------------------------------------------ |
| **`mediaIdentifier`** | <code>string</code> | Which media to query (only using for getMedia()) |


#### MediaAlbumResponse

| Prop         | Type                      |
| ------------ | ------------------------- |
| **`albums`** | <code>MediaAlbum[]</code> |


#### MediaAlbum

| Prop             | Type                                                               |
| ---------------- | ------------------------------------------------------------------ |
| **`identifier`** | <code>string</code>                                                |
| **`title`**      | <code>string</code>                                                |
| **`count`**      | <code>{ total?: number; photos?: number; videos?: number; }</code> |
| **`thumbnail`**  | <code>{ base64?: string; base64Raw?: string; }</code>              |
| **`type`**       | <code>'smart' \| 'shared' \| 'user' \| 'unfiltered'</code>         |


#### PluginListenerHandle

| Prop         | Type                                      |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |

</docgen-api>