Files
yellowjacket/frontend/bindings/yellowjacket/backend/player/player.ts
T
logan 867ced8c81 feat(player): leave the volume to the system where the system owns it
On Android the hardware keys are the volume control and the framework
mixes our stream against the device level, so a second control inside
the app moves something the user already moved.  Where that is true the
player's level sits at maximum, SetVolume / ChangeVolume / MuteToggle
are refused, and nothing persists a level nobody chose: restore
remembers the stored value instead of applying it, and saveState writes
that same value back rather than recording the synthetic maximum.

Mute is in that list because it is a level of zero by another name --
and because with no control rendered it would be the one state on such
a platform the user could not get out of.

The predicate is named after the capability rather than the platform,
because that is what makes it testable.  Only platformOwnsVolume is
behind a build tag, in two files that declare nothing else; everything
else is decided against Player.systemVolume, a field a test sets either
way.  That is mediacontrols' split, with androidpayload.go's reasoning
for keeping the contract out of a tagged file, and the tagged pair is
covered by a source sweep since no tier here compiles both halves.

SetDuck is deliberately untouched: it applies its attenuation by
re-applying the *user's* level through setVolumeLocked, so pinning that
level to maximum leaves the offset arithmetic exactly as it was.  It is
the only thing that may still move the output on such a platform, and
TestSystemVolumeStillDucks is that property rather than a comment.
2026-08-21 00:53:21 -04:00

173 lines
4.8 KiB
TypeScript

// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
/**
* Player handles audio playback and state management.
*
* Lock ordering: always acquire p.mu BEFORE speaker.Lock().
* The beep playback-finished callback dispatches to a new goroutine
* so it never holds p.mu while the speaker lock is held.
* @module
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Call as $Call, CancellablePromise as $CancellablePromise } from "@wailsio/runtime";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./models.js";
/**
* ChangeVolume adjusts the volume by a relative amount.
*/
export function ChangeVolume(deltaVolume: number): $CancellablePromise<void> {
return $Call.ByID(742861629, deltaVolume);
}
/**
* CurrentPosition returns the playback position as a percentage
* (0-100).
*/
export function CurrentPosition(): $CancellablePromise<number> {
return $Call.ByID(2723620683);
}
/**
* CurrentPositionSeconds returns the current playback position in
* display seconds.
*/
export function CurrentPositionSeconds(): $CancellablePromise<number> {
return $Call.ByID(1423359008);
}
/**
* EmitCurrentState pushes the current player state to the frontend.
* This is intended to be called after the frontend is ready to
* receive events, separately from RestoreState which does the heavy
* lifting during OnStartup.
*/
export function EmitCurrentState(): $CancellablePromise<void> {
return $Call.ByID(2143346946);
}
/**
* GetCurrentTrackInfo returns information about the currently
* loaded track.
*/
export function GetCurrentTrackInfo(): $CancellablePromise<$models.TrackInfo> {
return $Call.ByID(2615351053);
}
/**
* InitSpeaker initializes the audio output device. This is
* separated from NewPlayer so the player struct can be created
* before wails.Run (for binding registration) while deferring
* hardware initialization to OnStartup.
*/
export function InitSpeaker(): $CancellablePromise<void> {
return $Call.ByID(3317123670);
}
/**
* IsPlaying reports whether the player is currently playing audio.
*/
export function IsPlaying(): $CancellablePromise<boolean> {
return $Call.ByID(1219303535);
}
/**
* LoadFile opens and decodes an audio file for playback.
*/
export function LoadFile(filePath: string): $CancellablePromise<void> {
return $Call.ByID(2214941041, filePath);
}
/**
* MuteToggle toggles the mute state.
*/
export function MuteToggle(): $CancellablePromise<void> {
return $Call.ByID(2840614678);
}
/**
* Muted reports whether playback is currently silenced.
*/
export function Muted(): $CancellablePromise<boolean> {
return $Call.ByID(2954670878);
}
/**
* Pause pauses the current playback.
*/
export function Pause(): $CancellablePromise<void> {
return $Call.ByID(1402758839);
}
/**
* Play starts or resumes audio playback.
*/
export function Play(): $CancellablePromise<void> {
return $Call.ByID(3327176373);
}
/**
* RestoreState loads the persisted player state from the database.
*/
export function RestoreState(): $CancellablePromise<void> {
return $Call.ByID(318202560);
}
/**
* SaveState persists the current player state to the database and
* waits for the write. This is called during shutdown to capture the
* final state, which is the one case that cannot be deferred.
*/
export function SaveState(): $CancellablePromise<void> {
return $Call.ByID(3845072215);
}
/**
* Seek jumps to a specific position in seconds.
*/
export function Seek(targetSeconds: number): $CancellablePromise<void> {
return $Call.ByID(829056707, targetSeconds);
}
/**
* SetVolume sets the playback volume (0-100), emits a
* VolumeChanged event, and persists the new level.
*/
export function SetVolume(desiredVolume: $models.UserVolume): $CancellablePromise<void> {
return $Call.ByID(1375836663, desiredVolume);
}
/**
* SystemOwnsVolume reports whether the platform's own control is the
* only volume control there is, so this app neither offers one nor
* remembers a level.
*
* It is bound: the frontend renders no `<volume-control>` when it is
* true, at any width.
*/
export function SystemOwnsVolume(): $CancellablePromise<boolean> {
return $Call.ByID(1027623185);
}
/**
* TrackLengthInSeconds returns the duration of the current track.
*/
export function TrackLengthInSeconds(): $CancellablePromise<number> {
return $Call.ByID(3749851426);
}
/**
* UnloadTrack tears down the current track, releasing the file and
* streamer chain. The player returns to the initial "no track
* loaded" state and emits events so the frontend clears its
* current-track display.
*/
export function UnloadTrack(): $CancellablePromise<void> {
return $Call.ByID(3127425467);
}