Browse files

Merge branch 'mobile-controls' of github.com:smashcon/hisaishi into m…

…obile-controls

Conflicts:
	public/scripts/HisaishiPlayer.js
  • Loading branch information...
2 parents 2a205c3 + 0b80359 commit 4af3d2502f2dd643266b221930e978fe97f35364 @rtrvrtg rtrvrtg committed May 23, 2012
Showing with 50 additions and 8 deletions.
  1. +36 −5 hisaishi.rb
  2. +14 −3 public/scripts/HisaishiPlayer.js
View
41 hisaishi.rb
@@ -40,6 +40,12 @@
end
end
+def send_to_sockets(type, data={})
+ settings.sockets.each do |ws|
+ ws.send({:type => type, :data => data}.to_json)
+ end
+end
+
# ##### PLAYER ROUTES
@@ -192,6 +198,13 @@
q.unpause
end
+ # Tell the player we moved its cheese.
+ send_to_sockets("queue_update", {
+ :for => "player",
+ :queue_id => params[:q_id],
+ :action => params[:action]
+ })
+
redirect '/queue'
end
@@ -215,13 +228,24 @@
pin_auth!
q = HisaishiQueue.get(params[:q_id])
q.destroy
+ send_to_sockets("queue_update", {
+ :for => "player",
+ :action => "delete",
+ :queue_id => params[:q_id]
+ })
redirect '/queue'
end
post '/queue-reorder' do
pin_auth!
unless params[:queue].nil?
reorder_queue(params[:queue])
+
+ send_to_sockets("queue_update", {
+ :for => "player",
+ :action => "reorder",
+ :queue => params[:queue]
+ })
end
end
@@ -254,6 +278,12 @@
else
new_queue = song.enqueue(params[:requester])
+ send_to_sockets("queue_update", {
+ :for => "player",
+ :action => "add",
+ :song_id => params[:song_id]
+ })
+
haml :queue_song_ok, :locals => {
:song => song,
:new_queue => new_queue,
@@ -262,6 +292,7 @@
end
end
+# DEPRECATED
post '/queue-submit' do
authenticate!
@@ -302,11 +333,11 @@
post '/announce' do
text = params[:text]
new_ann = Announcement.create(
- :text => text,
- :ann_order => Announcement.all.length,
- :authed => has_admin_pin
- )
- redirect '/announce'
+ :text => text,
+ :ann_order => Announcement.all.length,
+ :authed => has_admin_pin
+ )
+ redirect '/announce'
end
get '/announce-add' do
View
17 public/scripts/HisaishiPlayer.js
@@ -1,6 +1,6 @@
/* Hisaishi List */
-if (!HisaishiEngine) {
+if (HisaishiEngine === undefined) {
throw {
type: 'NoHisaishiEngineException',
message: 'No Hisaishi engine script found.'
@@ -248,12 +248,21 @@ var HisaishiPlayer = function(params) {
// called whenever the queue gets reordered
reorder: function(e) {
+ // e.data.queue
+ // e.data.songs
+ console.log("reorder");
+ priv.fetchSource();
+ },
+
+ queue_update: function(e) {
+ console.log("queue update");
priv.fetchSource();
},
// called whenever *any* track gets played
play: function(e) {
// e.data.queue_id
+ console.log("play " + e.data.queue_id);
var oldQueueID = state.current_queue,
newQueueID = e.data.queue_id,
@@ -262,7 +271,7 @@ var HisaishiPlayer = function(params) {
if (oldQueueID != newTrackID) {
state.current_queue = newQueueID;
- foreach (var i in state.queue) {
+ for (var i in state.queue) {
if (state.queue.hasOwnProperty(i)) {
var q_item = state.queue[i];
if (q_item.id == newQueueID) {
@@ -280,11 +289,13 @@ var HisaishiPlayer = function(params) {
// called whenever the playing track is paused
pause: function(e) {
+ console.log("pause");
state.hs[state.track].pauseSong();
},
// called whenever the playing track is stopped
stop: function(e) {
+ console.log("stop");
state.hs[state.track].stopSong();
}
}
@@ -299,4 +310,4 @@ var HisaishiPlayer = function(params) {
pub.init();
return pub;
-};
+};

0 comments on commit 4af3d25

Please sign in to comment.