microphone

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package microphone exposes the microphone's PERMISSION state, not audio capture.

Recording is done in the WebView with getUserMedia + MediaRecorder, which works on every platform goleo targets and needs no Go code. What the WebView cannot do is tell you whether the OS has granted microphone access before you try, or ask for it without starting a capture — on mobile that is a native API. So this feature is deliberately small: two calls, and the Android manifest permission that registering it derives.

It exists as its own feature rather than as part of Camera on purpose. RECORD_AUDIO is a permission users see and Play flags, and most camera apps only want stills; folding it into RegisterCamera would declare it for all of them. An app that wants camera + audio registers both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PermissionGranted

func PermissionGranted() (bool, error)

func RequestPermission

func RequestPermission() (string, error)

func SetProvider

func SetProvider(p Provider)

Types

type Provider

type Provider interface {
	// PermissionGranted reports whether recording is currently allowed.
	PermissionGranted() bool
	// RequestPermission triggers the OS prompt and returns "granted", "denied" or
	// "default". "default" means the prompt is on screen and the answer is not known
	// yet — query again later rather than treating it as a refusal.
	RequestPermission() string
}

Provider is a native microphone backend. On mobile the shell registers one via SetProvider (RECORD_AUDIO checks on Android, AVAudioSession on iOS). Desktop has no equivalent to query, so the JS bridge falls back to getUserMedia, whose own prompt is the permission model there.

The method set mirrors notify.Notifier's deliberately: PermissionGranted/RequestPermission are shapes gobind binds cleanly to both Java and Swift (BOOL and NSString returns with no error result). A provider method returning (value, error) does NOT bind to Swift — see SPIKES.md, 2026-08-10.

Jump to

Keyboard shortcuts

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