media

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	Images = platform.MediaImages
	Videos = platform.MediaVideos
)

Variables

View Source
var (
	ErrUnsupported      = platform.ErrUnsupported
	ErrCanceled         = platform.ErrCanceled
	ErrNotAvailable     = platform.ErrNotAvailable
	ErrPermissionDenied = platform.ErrPermissionDenied
	ErrNotConfigured    = platform.ErrNotConfigured
)

Functions

func Pick

func Pick(a *tango.App, o PickOptions) ([]string, error)

Pick shows the photo picker and returns the chosen items' paths in the order picked.

func TakePhoto

func TakePhoto(a *tango.App) (string, error)

TakePhoto opens the camera and returns the path of the JPEG taken. ErrNotAvailable means the device has no camera (the iOS simulator).

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.

type Type

type Type = platform.MediaType

Type selects what Pick offers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL