play-url

Play the song at given URL. Supports Soundcloud, Youtube and Rdio URLs.

npm install play-url
10 downloads in the last week
15 downloads in the last month

play-url

Unified API for playing Youtube, Rdio, SoundCloud and Mp3 URLs.

player = require('play-url')(/* options */)

player.play('http://www.youtube.com/watch?v=fPjW1nwIdsY')
player.play('https://soundcloud.com/veyasin/mode-xl-bul-karayi')
player.play('http://www.rdio.com/artist/The_Chemical_Brothers/album/Push_The_Button/track/Galvanize/')
player.play('http://tayfabandista.org/player/haydi_barikata.mp3')

See test/index.js for more info.

Install

$ npm install play-url

Note: Despite this module using NPM, it is only for web-browsers, not for node.js. Learn more.

API

require('play-url')(options)

Pass SoundCloud and Rdio API keys:

player = require('play-url')({ soundcloud: 'api-key', rdio: { key: 'api-key', auth: 'auth.html' })

.play(url)

player.play('http://www.rdio.com/artist/The_Chemical_Brothers/album/Push_The_Button/track/Galvanize/')

.pause()

player.pause()

.playback()

Returns the active playback object.

player.playback.url
// => http://www.youtube.com/watch?v=fPjW1nwIdsY

You can subscribe to the changes on it:

player.playback.subscribe(function (newPlayback, oldPlayback) {
  console.log('Started playing %s', newPlayback.url)
})

.onPlay(callback)

player.onPlay(function () {
  player.playback().url
  // => http://www.youtube.com/watch?v=fPjW1nwIdsY
})

For once:

player.onPlay.subscribe.once(function () {

})

To unsubscribe:

player.onPlay.unsubscribe(`callback`)

.onEnd(callback)

npm loves you