Soundcloud Widget
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 = var iframe = 'id-of-soundcloud-iframe-on-page' // can also pass in an iframe nodevar widget = iframe
Methods
#on
A wrapper around the API's bind
method. bind
is also exposed if you prefer.
widget widgeton === widgetbind // true
See Events section for details.
#removeListener
A wrapper around the API's unbind
method. unbind
is also exposed if you prefer.
widget widget widget // the previous two listeners will no longer run widgetremoveListener === widgetunbind // 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.
widgetwidget 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 widgetwidget
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
other methods
AllThe 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 widget
Events
All the widget's events are stored on SoundcloudWidget.events
.