Documentation
¶
Overview ¶
Package media lets the user pick photos and videos from the library or take a photo with the camera.
paths, err := media.Pick(a, media.PickOptions{Limit: 5})
path, err := media.TakePhoto(a)
Pick uses the system picker (PHPickerViewController on iOS, the Android Photo Picker), which runs out of process and needs no photo library permission. TakePhoto uses the system camera UI (UIImagePickerController, ACTION_IMAGE_CAPTURE); iOS needs NSCameraUsageDescription (permission "camera" in tan.json) and returns ErrNotConfigured without it.
The returned paths are copies in the app's cache directory (iOS: Library/Caches/tango-media, Android: cache/tango-media), readable with os.Open; delete them when done. Canceling returns ErrCanceled.
Functions return ErrUnsupported where the backend has no picker or camera (desktop: use package dialog) and tango.ErrNotRunning after the app quit. On Android call them from a goroutine, not from a main-thread callback.
Index ¶
Constants ¶
const ( Images = platform.MediaImages Videos = platform.MediaVideos )
Variables ¶
var ( ErrUnsupported = platform.ErrUnsupported ErrCanceled = platform.ErrCanceled ErrNotAvailable = platform.ErrNotAvailable ErrPermissionDenied = platform.ErrPermissionDenied ErrNotConfigured = platform.ErrNotConfigured )
Functions ¶
Types ¶
type PickOptions ¶
type PickOptions struct {
Types Type // Images, Videos or both; 0 means Images
Limit int // most items the user may choose; 0 or 1 = one
// contains filtered or unexported fields
}
PickOptions configures Pick.