Dashing widget to play music. Awesome, right?!
A bit of a history. When we installed the Github's hubot, one of the things we were really miss was playing songs inside our room (not the whole office). The guys from Github have written play, but we just couldn't setup it (we didn't have Mac Mini at that moment - our CI monitors were backed by Ubuntu). So we started looking for another way out and decided to write Dashing widget and control it via hubot.
- Install Player widget
The files player.coffee
, player.html
and player.scss
go in the /widget/player
directory.
Otherwise you can install this plugin typing:
dashing install GIST_ID
-
Download JPlayer and put
jquery.jplayer.js
in your /assets/javascripts directory. It gets included automatically. -
Add the #player div after
gridster
div/ul element in your dashingboard.erb file:
<div class="gridster">
<ul>
...
</ul>
<div data-id="player" data-view="Player" data-title="player" data-min="0" data-max="100"></div>
</div>
- Dashing API
To be able to communicate with the widget we need an API (reasons explained below). Add this block to config.ru
after configure
section:
get '/api/:widget/:command' do
widget = params[:widget]
send_event(widget, params)
200
end
- If you are using Wavegirls widget, do not forget to add
'player'
toexcluded_dash_ids
(see additional configuration section for details).
Note: if you are using Github's Hubot, take a look at this script. It provides hubot commands to control player widget.
== /api/player/play?url={url}&title={title}
- play song or put it on the playlist if another song is already playing
- url - direct link to mp3
- title - song title
Example:
curl 'http://localhost:3030/api/player/play?url=http%3A//dl32.musload.com/loads/dlhash1/m05/h20/f630ba5ee4ff35cdc4416011291fcdad.mp3&title=Daughter%20-%20Get%20Lucky%20%28Daft%20Punk%20Cover%29'
== /api/player/next
- play next song
Example:
curl 'http://localhost:3030/api/player/next'
== /api/player/pause
- pause play
Example:
curl 'http://localhost:3030/api/player/pause'
== /api/player/resume
- resume play
Example:
curl 'http://localhost:3030/api/player/resume'
== /api/player/stop
- stop playing and clear playlist
Example:
curl 'http://localhost:3030/api/player/stop'
== /api/player/volume?value={value}
- set player volume to value
(0.0..1.0)
Example:
curl 'http://localhost:3030/api/player/volume?value=0.5'
how can I add the widget to the erb file in current version? jquery.jplayer.js doesn't exist in the new version 2.9 :/