livephoto

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package livephoto picks Live Photos and plays them inside your screen, on iOS. Android has no Live Photos: there Pick fails with plugin.Unavailable and View shows its Fallback.

nimbus native plugin add live-photo

p, err := livephoto.Pick(ctx)
if plugin.IsCode(err, plugin.Cancelled) { return }

livephoto.View{ID: p.ID, Style: ui.Style{Width: ui.Pt(320), Height: ui.Pt(320 / p.Aspect())}}

The picker hands the photo over itself, so it needs no photo library permission. A picked photo lasts until the app closes; Files gives its still and its video, to keep or upload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Forget

func Forget(ctx context.Context, id string) error

Forget lets go of a picked photo's memory before the app closes.

Types

type Media

type Media struct {
	Photo     []byte `json:"photo"`     // the still, usually HEIC
	PhotoType string `json:"photoType"` // its media type
	Video     []byte `json:"video"`     // the moment around it, a QuickTime movie
	VideoType string `json:"videoType"` // its media type
}

Media is a Live Photo's two halves.

func Files

func Files(ctx context.Context, id string) (Media, error)

Files gives a picked photo's still and video, to keep or upload.

type Photo

type Photo struct {
	ID     string `json:"id"`     // for View and Files
	Width  int    `json:"width"`  // in pixels
	Height int    `json:"height"` // in pixels
}

Photo is a Live Photo the app holds.

func Pick

func Pick(ctx context.Context) (Photo, error)

Pick shows the system's photo picker, with only Live Photos. Backing out fails with plugin.Cancelled.

func (Photo) Aspect

func (p Photo) Aspect() float32

Aspect is its width over its height, for sizing a View; 1 when unknown.

type View

type View struct {
	ID    string // from Pick
	Play  int    // raise it to play the photo once more, sound and all
	Muted bool   // plays without sound
	// Fill crops it to fill the frame; otherwise it fits inside.
	Fill  bool
	Style ui.Style // its size and place on the screen
	// Fallback is shown instead on Android. Nil leaves an empty space.
	Fallback ui.Component
}

View shows a picked Live Photo. Touching and holding it plays it, as in Photos.

func (View) Render

func (v View) Render(c *ui.Ctx) ui.Component

Render shows the photo, or Fallback on Android.

Jump to

Keyboard shortcuts

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