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
options
)
require('play-url')(Pass SoundCloud and Rdio API keys:
player = require('play-url')({ soundcloud: 'api-key', rdio: { key: 'api-key', auth: 'auth.html' })
url
)
.play(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)
})
callback
)
.onPlay(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`)