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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nativescript-sonos

v0.5.1

Published

Control Sonos systems from NativeScript apps

Downloads

8

Readme

NativeScript Sonos Plugin (WIP)

This plugin provides an interface for controlling a Sonos system on a local network from a NativeScript app. It is influenced heavily by the NodeJS Sonos library created by Ben Evans.

This is an incomplete, work-in-process plugin. Use accordingly.

Run the demo

After cloning this repo, navigate to the repo folder in your terminal and run this command:

$ npm run demo.ios

This will build the lastest version of the plugin, add it to the demo project and launch the demo in the emulator.

NOTE: The demo has only been tested for iOS, but the plugin should work on both iOS and Android.

How to use this plugin?

Add the plugin to a NativeScript application from the terminal:

$ tns plugin add nativescript-sonos

In your app, initialize the plugin with a valid Sonos IP address:

import { Sonos } from "nativescript-sonos"

let sonos = new Sonos("10.0.1.188"); //Replace with your Sonos IP address

You can now call methods to control a Sonos player. Unlike the original NodeJS library, this plugin uses Promises for all async methods. For example, to Play:

this.sonos.play()
  .then(() => {
    // Command to play completed successfully
  })
  .catch((err) => {
    // Something went wrong; handle the error state
  });

Supported operations

This plugin does not yet support all of the methods from the original NodeJS library. Currently implemented methods are:

  • currentTrack: () => Promise;
  • selectTrack: (trackNr?: number) => Promise;
  • getVolume: () => Promise;
  • setVolume: (volume: number) => Promise;
  • getMuted: () => Promise;
  • setMuted: (muted: boolean) => Promise;
  • play: (uri?: string | UriObject) => Promise;
  • stop: () => Promise;
  • pause: () => Promise;
  • seek: (seconds: number) => Promise;
  • next: () => Promise;
  • previous: () => Promise;
  • flush: () => Promise;
  • becomeCoordinatorOfStandaloneGroup: () => Promise;
  • setName: (name: any) => Promise;
  • setPlayMode: (playmode: PlayModeEnum) => Promise;
  • selectQueue: () => Promise;
  • queue: (uri: string | UriObject, positionInQueue?: number) => Promise;
  • getCurrentState: () => Promise;
  • getZoneInfo: () => Promise;
  • getZoneAttrs: () => Promise;
  • getZoneGroupState: () => Promise<SonosZoneGroup[]>;
  • getLEDState: () => Promise;
  • setLEDState: (setStateOn: boolean) => Promise;
  • getTopology: () => Promise;
  • getZonesWithDescriptions: () => Promise<SonosZone[]>;
  • deviceDescription: (host?: string, port?: number) => Promise;
  • getQueue: () => Promise;
  • getMusicLibrary: (searchType: SonosSearchType, startIndex?: number, pageSize?: number) => Promise;
  • searchMusicLibrary: (searchType: SonosSearchType, searchTerm: string, startIndex?: number, pageSize?: number) => Promise;
  • getFavoritesRadioStations: (startIndex?: number, pageSize?: number) => Promise;
  • getFavoritesRadioShows: (startIndex?: number, pageSize?: number) => Promise;
  • getFavoritesRadio: (favoriteRadioType: any, startIndex?: number, pageSize?: number) => Promise;
  • playTuneinRadio: (stationId: any, stationTitle: any) => Promise;
  • addSpotify: (trackId: any) => Promise;
  • playSpotifyRadio: (artistId: any, artistName: any) => Promise;
  • addSpotifyQueue: (trackId: any) => Promise;

Sonos device discovery APIs

This plugin does not yet support the Discovery APIs (allowing you to automatially locate Sonos devices on the network) due to the lack of support in NativeScript for UDP socket connections.

When UDP socket connections become possible, Discovery APIs should be possible in NativeScript.

Contributions welcome. 😀

What's next?

Additional Sonos APIs from the NodeJS library will be exposed in this plugin. If there is an API you need that is not yet exposed, open an Issue and we'll try to prioritize it.

Contributions and constructive feedback welcome.

License

MIT. Use it, transform it, whatever.