starti.app
API Reference

Media

Control the device's system volume. Set an exact level, nudge it up or down by one step, or read the current value. You can also listen for volume changes made by the user (hardware buttons, Control Center, etc.).

Access: startiapp.Media

Methods

setVolume(newVolume): Promise<void>

Sets the system volume to the specified value.

Parameters:

ParameterTypeRequiredDescription
newVolumenumberYesTarget volume level between 0 (muted) and 1 (maximum).

Returns: Promise<void> —Resolves when the volume has been set.

Example:

// Set volume to 50 %
await startiapp.Media.setVolume(0.5);

getVolume(): Promise<number>

Gets the current system volume.

Returns: Promise<number> —The current volume level between 0 and 1.

Example:

const volume = await startiapp.Media.getVolume();
console.log(`Current volume: ${volume * 100}%`);

increaseVolume(): Promise<void>

Increases the system volume by one step (the same increment as pressing the hardware volume-up button).

Returns: Promise<void> —Resolves when the volume has been increased.

Example:

await startiapp.Media.increaseVolume();

decreaseVolume(): Promise<void>

Decreases the system volume by one step (the same decrement as pressing the hardware volume-down button).

Returns: Promise<void> —Resolves when the volume has been decreased.

Example:

await startiapp.Media.decreaseVolume();

Events

volumeChanged

Fired whenever the system volume changes, whether triggered by your app, the user pressing hardware buttons, or system-level adjustments.

The event's detail property contains a VolumeChangedEventArgs object.

Example:

startiapp.Media.addEventListener("volumeChanged", (event) => {
  const { volume } = event.detail;
  console.log(`Volume changed to ${volume}`);
});

Types

VolumeChangedEventArgs

Event payload attached to the volumeChanged event.

interface VolumeChangedEventArgs {
  /** The new volume level (0 to 1). */
  volume: number;
}

On this page