Skip to content

NowPlaying Addon

Read active media session metadata and control playback — play, pause, skip, seek, shuffle, and repeat.

javascript
import { addon } from "novadesk";
const nowPlaying = addon.load("path/to/NowPlaying.dll");

Table of Contents


nowPlaying.stats() #
NowPlaying

Returns current media session metadata. Call on a short interval (500–1000ms) to keep the UI updated.

Property Type Description
available boolean true when a media session is active.
player string Player/app name.
artist string Track artist.
album string Track album.
title string Track title.
thumbnail string Cached thumbnail path, or empty string.
duration number Track duration in seconds.
position number Current playback position in seconds.
progress number Playback progress 0–100.
state number 0 = stopped/unknown, 1 = playing, 2 = paused.
status number 0 = closed, 1 = opened.
shuffle boolean Shuffle state.
repeat boolean Repeat state.
RETURNS: object An object with media session details. Always returns an object — check available before using other fields.
javascript
const s = nowPlaying.stats();

if (s.available) {
  console.log(s.artist, "-", s.title);
  console.log("Progress:", s.progress + "%");
} else {
  console.log("Nothing playing");
}

nowPlaying.backend() #
NowPlaying

Returns the active backend name.

RETURNS: string "winrt" when the backend is active, "disabled" otherwise.
javascript
console.log("Backend:", nowPlaying.backend());

Playback Controls

All playback control functions return true if the action was queued (backend is enabled), false otherwise.

nowPlaying.play() #
NowPlaying

Sends a play command to the active media session.

RETURNS: boolean true if the command was sent to the active session.
javascript
nowPlaying.play();

nowPlaying.pause() #
NowPlaying

Sends a pause command to the active media session.

RETURNS: boolean true if the command was sent to the active session.
javascript
nowPlaying.pause();

nowPlaying.playPause() #
NowPlaying

Toggles play/pause on the active media session.

RETURNS: boolean true if the command was sent to the active session.
javascript
nowPlaying.playPause();

nowPlaying.stop() #
NowPlaying

Stops the active media session.

RETURNS: boolean true if the command was sent to the active session.
javascript
nowPlaying.stop();

nowPlaying.next() #
NowPlaying

Skips to the next track.

RETURNS: boolean true if the command was sent to the active session.
javascript
nowPlaying.next();

nowPlaying.previous() #
NowPlaying

Goes to the previous track.

RETURNS: boolean true if the command was sent to the active session.
javascript
nowPlaying.previous();

nowPlaying.setPosition(value [, isPercent]) #
NowPlaying

Seeks to a position in the current track.

PARAMETERS

value number
Position in seconds, or 0–100 percent if isPercent is true. Throws TypeError if not a number.
isPercent boolean OPTIONAL
true to interpret value as a percentage of track duration. Defaults to false.
RETURNS: boolean true if the seek command was sent, false otherwise.
javascript
// Seek to 30 seconds
nowPlaying.setPosition(30);

// Seek to 50% of the track
nowPlaying.setPosition(50, true);

nowPlaying.setShuffle(enabled) #
NowPlaying

Sets the shuffle state of the active media session.

PARAMETERS

enabled boolean
true to enable shuffle, false to disable.
RETURNS: boolean true if the command was sent.
javascript
nowPlaying.setShuffle(true);

nowPlaying.toggleShuffle() #
NowPlaying

Toggles shuffle on the active media session.

RETURNS: boolean true if the command was sent.
javascript
nowPlaying.toggleShuffle();

nowPlaying.setRepeat(mode) #
NowPlaying

Sets the repeat mode of the active media session.

PARAMETERS

mode number
0 = no repeat, 1 = repeat one track, 2 = repeat all. Throws TypeError if not a number.
RETURNS: boolean true if the command was sent.
javascript
nowPlaying.setRepeat(2); // repeat all
nowPlaying.setRepeat(0); // no repeat