appVolume Module
Manage per-application audio session volume and mute state in Novadesk.
The appVolume module is exported from the system module.
javascript
import { appVolume } from "system";Table of Contents
appVolume.listSessions()
Returns active output audio sessions.
Return Value
- Type:
object[] - Description: Array of session objects with:
pid(number): Process ID.processName(string): Process file name.fileName(string): Executable file name.filePath(string): Full executable path when available.iconPath(string): Extracted icon path when available, otherwise empty string.displayName(string): Session display name.volume(number): Session volume in0.0-1.0.peak(number): Peak level in0.0-1.0(currently0).muted(boolean): Session mute state.
If session enumeration fails, an empty array is returned.
appVolume.getByPid(pid)
Gets aggregated volume details for all active sessions matching a PID.
Parameters
pid- Type:
number - Description: Target process ID. Must be greater than
0.
- Type:
Return Value
- Type:
object | null - Description:
- Returns
nullwhen no active session matches the PID. - Otherwise returns:
volume(number): Average volume of matching sessions (0.0-1.0).muted(boolean):trueif any matching session is muted.peak(number): Maximum peak across matching sessions.
- Returns
appVolume.getByProcessName(name)
Gets aggregated volume details for all active sessions matching a process name.
Parameters
name- Type:
string - Description: Process name match (case-insensitive), usually executable file name like
"chrome.exe".
- Type:
Return Value
- Type:
object | null - Description: Same shape and behavior as
getByPid().
appVolume.setVolumeByPid(pid, volume01)
Sets volume for all active sessions matching a PID.
Parameters
pid- Type:
number - Description: Target process ID. Must be greater than
0.
- Type:
volume01- Type:
number - Description: Target volume in
0.0-1.0. Values outside this range are clamped.
- Type:
Return Value
- Type:
boolean - Description:
trueif at least one matching active session was updated; otherwisefalse.
appVolume.setVolumeByProcessName(name, volume01)
Sets volume for all active sessions matching a process name.
Parameters
name- Type:
string - Description: Process name match (case-insensitive).
- Type:
volume01- Type:
number - Description: Target volume in
0.0-1.0. Values outside this range are clamped.
- Type:
Return Value
- Type:
boolean - Description:
trueif at least one matching active session was updated; otherwisefalse.
appVolume.setMuteByPid(pid, mute)
Sets mute state for all active sessions matching a PID.
Parameters
pid- Type:
number - Description: Target process ID. Must be greater than
0.
- Type:
mute- Type:
boolean - Description:
trueto mute,falseto unmute.
- Type:
Return Value
- Type:
boolean - Description:
trueif at least one matching active session was updated; otherwisefalse.
appVolume.setMuteByProcessName(name, mute)
Sets mute state for all active sessions matching a process name.
Parameters
name- Type:
string - Description: Process name match (case-insensitive).
- Type:
mute- Type:
boolean - Description:
trueto mute,falseto unmute.
- Type:
Return Value
- Type:
boolean - Description:
trueif at least one matching active session was updated; otherwisefalse.
Example
javascript
import { appVolume } from "system";
const sessions = appVolume.listSessions();
console.log("sessions:", sessions.length);
if (sessions.length > 0) {
const first = sessions[0];
console.log("first session:", first.processName, first.volume, first.muted);
// Set session group by process name to 50% volume.
appVolume.setVolumeByProcessName(first.processName, 0.5);
// Mute and unmute by PID.
appVolume.setMuteByPid(first.pid, true);
appVolume.setMuteByPid(first.pid, false);
const stats = appVolume.getByPid(first.pid);
console.log("aggregated:", stats);
}