All Projects → azer → play-url

azer / play-url

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

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
coffeescript
4710 projects

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)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].