Skip to content

Volume

Volume is another kit surface nomercy-video-player inherits unchanged — there’s no video-specific volume behavior, the backend just needs a real <audio>/<video> gain to move.

Reading and setting the level

volume() reads the current level as a number in [0, 100]; volume(level) sets it, clamped to that range, and returns a Promise<void> once the backend applies it:

TypeScript
import nmplayer from '@nomercy-entertainment/nomercy-video-player';

const player = nmplayer('player');

const level = player.volume(); // 0-100
await player.volume(50);

Set an initial level through setup({ defaultVolume }), a number on the same 0-100 scale that defaults to 100. A player with no defaultVolume starts at full gain, so read a saved preference into that config field, or call volume() yourself after ready() if you’d rather set it later.

Mute

mute() and unmute() are absolute; toggleMute() flips based on the current state. All three dispatch beforeMute first, same cancellable shape as transport, and no-op (never dispatch) when already in the target state:

TypeScript
await player.mute();
await player.unmute();
player.toggleMute();

volumeUp(step?) and volumeDown(step?) nudge the level by step (5 by default), clamped to [0, 100] the same as a direct volume() call — the pair a keyboard shortcut or remote’s volume rocker binds to.

Reading the gain stage

volumeState() returns a typed VolumeState.UNMUTED or VolumeState.MUTED — the value a mute-icon component reads instead of tracking its own boolean, since it stays correct even when something other than that icon (a keyboard shortcut, a Connect sync) changes the mute state:

TypeScript
import { VolumeState } from '@nomercy-entertainment/nomercy-video-player';

if (player.volumeState() === VolumeState.MUTED) {
// show the muted icon
}

volume, mute, and beforeVolume/beforeMute events carry { level } / { muted } payloads respectively — subscribe to those instead of polling the getters from a render loop.

Next steps

  • The Queue & Playlist: the cursor-aware list next(), previous(), and item() read from and move through.