npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@coooookies/windows-smtc-monitor

v1.0.12

Published

Fetch Windows SMTC media player information and listen for media control events (e.g., play, pause, skip). Suitable for Windows 1809 and later.

Readme

Node-Windows-SMTC-Monitor

Screenshot

This is a Node.js toolkit for listening to SMTC (System Media Transport Controls) media events in Windows. It is written in Rust and utilizes napi-rs to implement bindings with Node.js.

⚠️ Warning

node-windows-smtc-monitor only supports Windows 10 1809 and later versions (>= 10.0.17763)

🚀 Features

  • Listen to media events such as play, pause, next track, previous track.
  • Get the current playback state and track information.
  • Support for both JavaScript and TypeScript.
  • Easy to use and integrate into existing Node.js applications.

Installation

npm i @coooookies/windows-smtc-monitor

🍊 Example

CommonJS Example ESModule Example TypeScript Example

Usage

Importing the library

// Typescript & ESModule
import { SMTCMonitor } from '@coooookies/windows-smtc-monitor';

// CommonJS
const { SMTCMonitor } = require('@coooookies/windows-smtc-monitor');

Gets all media sessions

Gets all of the available sessions.

const sessions = SMTCMonitor.getMediaSessions(); // MediaInfo[]
// [
//   {
//     sourceAppId: 'PotPlayerMini64.exe',
//     media: {
//       title: 'ぱられループ を歌ってみた (Jeku remix)',
//       artist: 'Jeku/aori',
//       albumTitle: '',
//       albumArtist: 'ぱられループ を歌ってみた (Jeku remix)',
//       genres: [],
//       albumTrackCount: 0,
//       trackNumber: 0,
//       thumbnail: <Buffer 42 4d 0e ... 1048526 more bytes> // The Album Cover/Thumbnail in Buffer
//     },
//     playback: { playbackStatus: 4, playbackType: 1 },
//     timeline: { position: 217.228, duration: 259 },
//     lastUpdatedTime: 1740000000000
//   },
//   {
//     sourceAppId: 'player.exe',
//     media: { ... },
//     playback: { ... },
//     timeline: { ... },
//     lastUpdatedTime: 1740000000000
//   }
// ]

Gets the current media session

Gets the current session. This is the session the system believes the user would most likely want to control.

const session = SMTCMonitor.getCurrentMediaSession(); // MediaInfo | null
// {
//   sourceAppId: 'PotPlayerMini64.exe',
//   media: { ... },
//   playback: { ... },
//   timeline: { ... },
//   lastUpdatedTime: 1740000000000
// }

Gets the specified media session

Gets the specified session by the sourceAppId.

const session = SMTCMonitor.getMediaSessionByAppId('player.exe'); // MediaInfo | null
// {
//   sourceAppId: 'player.exe',
//   media: { ... },
//   playback: { ... },
//   timeline: { ... },
//   lastUpdatedTime: 1740000000000
// }

Using Listeners

If you need to continuously listen for media events, you might consider using the getMediaSessions method for polling. However, this approach can be resource-intensive. Instead, node-windows-smtc-monitor provides a listener class that allows you to listen for events such as GlobalSystemMediaTransportControlsSessionManager.CurrentSessionChanged GlobalSystemMediaTransportControlsSessionManager.SessionsChanged and other related events to monitor media sessions efficiently.

// Register the monitor
const monitor = new SMTCMonitor();

// Normal use
monitor.on('session-media-changed', (appId, mediaProps) => {
  console.log(`Media info changed for ${appId}`, mediaProps);
});

// Using a listener defined outside
const listener = (appId, playbackInfo) => {
  console.log(`Playback state changed for ${appId}`, playbackInfo);
};

monitor.on('session-playback-changed', listener); // Register the listener
monitor.off('session-playback-changed', listener); // Unregister the listener

console.log(monitor.sessions)
// Shows all the sessions

// Destroy monitoring when done
// monitor.destroy();

Here is a list of available events:

| Event Name | Description | Parameters | | ------------------------ | ------------------------------------------- | --------------------------------------------- | | session-media-changed | Triggered when media info changes | (appId: string, mediaProps: MediaProps) | | session-timeline-changed | Triggered when position or duration changes | (appId: string, timelineProps: TimelineProps) | | session-playback-changed | Triggered when playback state changes | (appId: string, playbackInfo: PlaybackInfo) | | session-added | Triggered when a new media session is added | (appId: string, mediaInfo: MediaInfo) | | session-removed | Triggered when a media session is removed | (appId: string) | | current-session-changed | Triggered when the current session changes | (appId: string) |

Using in Electron

To use node-windows-smtc-monitor in Electron, you need to run it in a Worker thread. Running it in the main process will cause the main thread to lock up, which will freeze the renderer process. An example of how to use it in a Worker is provided in example/worker.js.

Worker Example

License

This project is licensed under the MIT License.