capacitor-viber-gallery-picker
v1.2.3
Published
Viber-like media picker with live camera preview and gallery selection
Maintainers
Readme
Capacitor Viber Gallery Picker
A Capacitor plugin that provides Viber-like media picker functionality with gallery access and camera capture.
Features
- Get gallery media with pagination (images and videos)
- Capture photos and videos
- Get media thumbnails
- Get full media data (base64)
- Works on Android, iOS, and Web
Installation
In your Capacitor project
npm install /path/to/capacitor-viber-gallery-picker
npx cap syncIn your Next.js project
npm install /path/to/capacitor-viber-gallery-pickerUsage
import { ViberGalleryPicker } from '@capacitor-viber-gallery-picker';
// Get gallery media with pagination
const result = await ViberGalleryPicker.getGalleryMedia({
limit: 20,
offset: 0,
mediaType: 'all'
});
// Capture photo
const photo = await ViberGalleryPicker.capturePhoto({ quality: 100 });
// Capture video
const video = await ViberGalleryPicker.captureVideo({
quality: 100,
maxDuration: 60
});
// Get thumbnail
const thumbnail = await ViberGalleryPicker.getMediaThumbnail({
identifier: 'media-id',
size: 200
});
// Get full media data
const mediaData = await ViberGalleryPicker.getMediaData({
identifier: 'media-id'
});API
getGalleryMedia(options?)
Get media from gallery with pagination.
Options:
limit?: number- Number of items to fetch (default: 50)offset?: number- Offset for pagination (default: 0)mediaType?: 'all' | 'images' | 'videos'- Filter by type (default: 'all')
Returns:
media: MediaItem[]- Array of media itemshasMore: boolean- Whether there are more itemstotalCount: number- Total count of media
capturePhoto(options?)
Capture a photo using the camera.
Options:
quality?: number- Image quality 0-100 (default: 100)
Returns:
path: string- File pathbase64?: string- Base64 encoded imagetype: 'image'- Media type
captureVideo(options?)
Capture a video using the camera.
Options:
quality?: number- Video quality (default: 100)maxDuration?: number- Max duration in seconds (default: 60)
Returns:
path: string- File pathbase64?: string- Base64 encoded videotype: 'video'- Media type
getMediaThumbnail(options)
Get thumbnail for a media item.
Options:
identifier: string- Media identifiersize?: number- Thumbnail size (default: 200)
Returns:
thumbnail: string- Base64 thumbnail data URL
getMediaData(options)
Get full media data.
Options:
identifier: string- Media identifier
Returns:
path: string- File pathbase64: string- Base64 encoded mediatype: 'image' | 'video'- Media type
Permissions
Android
Add to AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />The plugin uses the Android Photo Picker on API 33+ and the Storage Access Framework below that level, so do not declare
READ_MEDIA_*orREAD_EXTERNAL_STORAGEpermissions in your app. Google Play will reject builds that keep those entries without a core media-management use case.
iOS
Add to Info.plist:
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library</string>
<key>NSCameraUsageDescription</key>
<string>We need access to your camera</string>