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 🙏

© 2024 – Pkg Stats / Ryan Hefner

soundcloud-widget

v0.2.1

Published

A wrapper around the Soundcloud widget js.

Downloads

704

Readme

Soundcloud Widget

Greenkeeper badge

This is a commonjs wrapper around the Soundcloud Widget JavaScript file allowing you to require it in your Browserify/Webpack projects.

For some examples, go here.

Usage

Initialization

var SoundcloudWidget = require('soundcloud-widget')
var iframe = 'id-of-soundcloud-iframe-on-page' // can also pass in an iframe node
var widget = new SoundcloudWidget(iframe)

Methods

#on

A wrapper around the API's bind method. bind is also exposed if you prefer.

widget.on(SoundcloudWidget.events.PLAY, function () {
  // code to run when player starts to play
})

widget.on === widget.bind // true

See Events section for details.

#removeListener

A wrapper around the API's unbind method. unbind is also exposed if you prefer.

widget.on(SoundcloudWidget.events.PLAY, function () {
  // code to run when player starts to play
})

widget.on(SoundcloudWidget.events.PLAY, function () {
  // more code
})

widget.removeListener(SoundcloudWidget.events.PLAY) // the previous two listeners will no longer run

widget.removeListener === widget.unbind // true

#load

A wrapper around the API's load method. Instead of passing a callback parameter in the options hash, the function returns a promise. Use that to determine when the song has been loaded.

widget.load('some soundcloud url')
widget.load('some soundcloud url').then(function () {
  // sound has been loaded
})

var options = { // default values displayed
  auto_play: false,
  buying: true,
  liking: true,
  download: true,
  sharing: true,
  show_artwork: true,
  show_comments: true,
  show_playcount: true,
  show_user: true,
  start_track: 0 // for playlists
}

widget.load('some soundcloud url', options)
widget.load('some soundcloud url', options).then(function () {
  // sound has been loaded
})

If your code style prefers camel case parameters, you can pass in camel case versions of the snake case parameters instead.

var options = {
  autoPlay: false,
  showArtwork: true,
  showComments: true,
  showPlaycount: true,
  showUser: true,
  startTrack: 0
}

widget.load('some soundcloud url', options)

All other methods

The rest of the methods behave the same as the documentation describes.

Getters

The getters in the widget API take callbacks. All the same methods are provided here, but they are promises instead.

widget.getVolume().then(function (volume) {
  // update ui with volume param
})

widget.getCurrentSound().then(function (soundObject) {
  // update ui with soundObject
})

Events

All the widget's events are stored on SoundcloudWidget.events.