2.0.4 • Published 8 years ago

react-soundcloud-widget v2.0.4

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

react-soundcloud-widget Build Status

Simple React component acting as a thin layer over the SoundCloud HTML5 Widget.

Features

  • url playback
  • customizable widget options
  • playback event bindings
  • lazy API loading

Installation

$ npm install react-soundcloud-widget

Usage

<SoundCloud
  url={string}         // required
  id={string}          // defaults -> 'react-sc-widget'
  opts={object}        // defaults -> './lib/default-options'
  onPlay={func}        // defaults -> noop
  onPause={func}       // defaults -> noop
  onEnd={func}         // defaults -> noop
/>

Example

class Example extends Component {
  onPlay() {
    console.log('playing');
  }

  render() {
    return (
      <SoundCloud
        url={'https://soundcloud.com/sylvanesso/coffee'}
        onPlay={this.onPlay}
      />
    );
  }
}

Widget options

Boolean toggles passed via props.opts

ParameterPurposeDefault
auto_playStart playing the widget after it’s loadedtrue
visualDisplay widget in visual mode.false
buyingShow/hide buy buttonstrue
likingShow/hide like buttonstrue
downloadShow/hide download buttonstrue
sharingShow/hide share buttons/dialoguestrue
show_artworkShow/hide artworktrue
show_commentsShow/hide commentstrue
show_playcountShow/hide number of sound playstrue
show_userShow/hide the uploader nametrue
show_repostsShow/hide repostsfalse
hide_relatedShow/hide related tracksfalse

Warning

Changing props.url currently adds an entry to window.history, breaking the back button (or at least adding another click to it).

You can see this in action at http://troybetz.com/react-soundcloud-widget/, change the url using the button and try navigating back.

This is outside my control for now, the widget used internally is served up and managed by SoundCloud. Super bummer.

Caveat

Programmatic control of the widget as outlined in the API docs isn't included. Luckily, the API loads alongside the widget, so taking control is as easy as:

var widget = SC.Widget('react-sc-player');
// do stuff

The component itself uses SC.Widget.load, SC.Widget.bind and SC.Widget.unbind internally. Using those methods outside the component may cause problems.

License

MIT

2.0.4

8 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago