recording_helpers.ts

Pure helpers for recording audio in the browser.

view source

Declarations
#

9 declarations

confirm_unload_while_recording
#

recording_helpers.ts view source

(event: BeforeUnloadEvent, recorder: { readonly active: boolean; } | undefined): void import {confirm_unload_while_recording} from '@fuzdev/zzz/recording_helpers.js';

Handles beforeunload: while the microphone is live, asks the browser to confirm leaving the page, since that ends the recording.

event

the beforeunload event

type BeforeUnloadEvent

recorder

the app's recorder, if there's an app

type { readonly active: boolean; } | undefined

returns

void

mutates

  • event — cancels it (`preventDefault` plus the legacy `returnValue`) to ask for confirmation

format_recording_duration
#

recording_helpers.ts view source

(ms: number): string import {format_recording_duration} from '@fuzdev/zzz/recording_helpers.js';

Formats a duration as m:ss, or h:mm:ss from an hour up.

ms

the duration in milliseconds

type number

returns

string

pick_recording_format
#

recording_helpers.ts view source

(is_type_supported: (mime_type: string) => boolean): RecordingFormat | null import {pick_recording_format} from '@fuzdev/zzz/recording_helpers.js';

Picks the first of RECORDING_FORMATS the browser can record.

is_type_supported

MediaRecorder.isTypeSupported

type (mime_type: string) => boolean

returns

RecordingFormat | null

the format, or null when the browser records none of them

RECORDING_FORMATS
#

recording_helpers.ts view source

readonly RecordingFormat[]

type readonly RecordingFormat[]

import {RECORDING_FORMATS} from '@fuzdev/zzz/recording_helpers.js';

The formats a recording is made in, most preferred first: Opus in WebM, Opus in Ogg, then whatever the browser puts in MP4.

RecordingFormat
#

recording_helpers.ts view source

RecordingFormat import type {RecordingFormat} from '@fuzdev/zzz/recording_helpers.js';

A container and codec the browser can record, and the extension its files get.

mime_type

The MediaRecorder MIME type.

type string

extension

The file extension, without the dot — one the backend can finalize and serve.

type string

RECORDINGS_DIRNAME
#

recording_helpers.ts view source

"recordings" import {RECORDINGS_DIRNAME} from '@fuzdev/zzz/recording_helpers.js';

The directory under the app directory that the recordings page records to.

to_microphone_error_message
#

recording_helpers.ts view source

(error: unknown): string import {to_microphone_error_message} from '@fuzdev/zzz/recording_helpers.js';

Says why the microphone couldn't be opened, from the error getUserMedia rejected with.

error

the rejection

type unknown

returns

string

to_recording_name
#

recording_helpers.ts view source

(date: Date): string import {to_recording_name} from '@fuzdev/zzz/recording_helpers.js';

Names a recording by when it started, in local time: 2026-01-31_09-05-07. Sorts by time and has no character a filesystem or a shell minds.

date

when the recording started

type Date

returns

string

to_recordings_dir
#

recording_helpers.ts view source

(zzz_dir: string): string import {to_recordings_dir} from '@fuzdev/zzz/recording_helpers.js';

The directory the recordings page records to: recordings/ in the app directory. It needs no open workspace, and keeps voice notes out of whatever repository a workspace is.

zzz_dir

the app directory, with its trailing slash

type string

returns

string

Imported by
#