https://github.com/azer/play-url
Unified API for playing Youtube, Rdio, SoundCloud and Mp3 URLs.
https://github.com/azer/play-url
Last synced: 12 months ago
JSON representation
Unified API for playing Youtube, Rdio, SoundCloud and Mp3 URLs.
- Host: GitHub
- URL: https://github.com/azer/play-url
- Owner: azer
- Created: 2013-10-05T22:53:14.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2016-12-29T16:50:24.000Z (over 9 years ago)
- Last Synced: 2025-06-20T15:52:58.663Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 19
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## play-url
Unified API for playing Youtube, Rdio, SoundCloud and Mp3 URLs.
```js
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
```bash
$ npm install play-url
```
Note: Despite this module using NPM, it is only for web-browsers, not for node.js. [Learn more.](https://github.com/azer/play-url/issues/1)
## API
### require('play-url')(`options`)
Pass SoundCloud and Rdio API keys:
```js
player = require('play-url')({ soundcloud: 'api-key', rdio: { key: 'api-key', auth: 'auth.html' })
```
#### .play(`url`)
```js
player.play('http://www.rdio.com/artist/The_Chemical_Brothers/album/Push_The_Button/track/Galvanize/')
```
#### .pause()
```js
player.pause()
```
#### .playback()
Returns the active playback object.
```js
player.playback.url
// => http://www.youtube.com/watch?v=fPjW1nwIdsY
```
You can subscribe to the changes on it:
```js
player.playback.subscribe(function (newPlayback, oldPlayback) {
console.log('Started playing %s', newPlayback.url)
})
```
#### .onPlay(`callback`)
```js
player.onPlay(function () {
player.playback().url
// => http://www.youtube.com/watch?v=fPjW1nwIdsY
})
```
For once:
```js
player.onPlay.subscribe.once(function () {
})
```
To unsubscribe:
```js
player.onPlay.unsubscribe(`callback`)
```
#### .onEnd(`callback`)