NowPlaying Addon
The NowPlaying addon reads active media metadata and lets you control playback (play/pause/next/previous).
Table of Contents
Quick Start
Load the addon DLL and call the functions directly.
javascript
import { addon } from "novadesk";
const nowPlaying = addon.load("D:/Novadesk-Project/NowPlaying/dist/x64/Debug/NowPlaying.dll");
const stats = nowPlaying.stats();
console.log(stats.title, stats.artist, stats.position, "/", stats.duration);
nowPlaying.playPause();stats()
Returns current media session details.
Return Value
- Type:
object - Description: Always returns an object with:
available(boolean)player(string)artist(string)album(string)title(string)thumbnail(string): Cached thumbnail path (empty string if unavailable)duration(number): Track duration in secondsposition(number): Current playback position in secondsprogress(number): Playback progress (0-100)state(number):0stopped/unknown,1playing,2pausedstatus(number):0closed,1openedshuffle(boolean)repeat(boolean)
INFO
If nothing is playing, available is false and the rest of the fields are empty/default values.
backend()
Returns active now-playing backend name.
Return Value
- Type:
string - Description: Returns
"winrt"when enabled or"disabled"otherwise.
Playback Controls
These functions return true if the action was queued (backend enabled), otherwise false.
play()pause()playPause()stop()next()previous()
setPosition(value[, isPercent])
Sets playback position.
Parameters
value(number): Position in seconds, or percent ifisPercentistrue.isPercent(boolean, optional, defaultfalse): Interpretvalueas0-100percent.
Return Value
- Type:
boolean
INFO
When isPercent is true, the seek time is computed from current track duration.
setShuffle(enabled)
Enable or disable shuffle.
enabled(boolean)- Returns:
boolean
toggleShuffle()
Toggles shuffle state.
- Returns:
boolean
setRepeat(mode)
Sets repeat mode.
mode(number)0none1track (repeat one)2list (repeat all)
- Returns:
boolean
Error Behavior
setPosition(value[, isPercent])throws a type error whenvalueis not numeric.setRepeat(mode)throws a type error whenmodeis not numeric.
Beginner Tips
- Call
stats()on a short interval (500–1000ms) to refresh the UI. - Use
availableto hide controls when nothing is playing. - Use
progressif you want a quick slider without calculating time.
Example
javascript
import { addon } from "novadesk";
const nowPlaying = addon.load("D:/Novadesk-Project/NowPlaying/dist/x64/Debug/NowPlaying.dll");
console.log("backend:", nowPlaying.backend());
const stats = nowPlaying.stats();
console.log("available:", stats.available);
console.log("player:", stats.player, "title:", stats.title, "progress:", stats.progress + "%");
nowPlaying.playPause();
nowPlaying.setShuffle(true);
nowPlaying.setRepeat(2);
nowPlaying.setPosition(50, true);