Skip to content
Browse files

fixed set volume after pause/next

  • Loading branch information...
1 parent cf83f01 commit 4b27a354952196dd307a2607b3f673933c6a75bc @msoap committed Feb 3, 2013
Showing with 20 additions and 16 deletions.
  1. +11 −8 mojolicious-radio-box.pl
  2. +9 −8 src/radio-box-client.coffee
View
19 mojolicious-radio-box.pl
@@ -535,6 +535,9 @@ sub _cmus_parse_info {
update_info: function() {
return $.get('/get_info', function(info_data) {
App.info = info_data.info;
+ if (App.info.volume != null) {
+ App.volume = App.info.volume;
+ }
return App.render_info();
});
},
@@ -570,8 +573,8 @@ sub _cmus_parse_info {
App.do_get_radio();
}
}
- if (App.info.volume != null) {
- return $('input#volume_slider').val(App.info.volume);
+ if (App.volume != null) {
+ return $('input#volume_slider').val(App.volume);
}
},
render_select_radio: function() {
@@ -671,13 +674,13 @@ sub _cmus_parse_info {
App._change_valume_tid = void 0;
}
new_volume = 0;
- if (event.data.up) {
- new_volume = App.info.volume + event.data.up;
+ if (event.data.up && (App.volume != null)) {
+ new_volume = App.volume + event.data.up;
if (new_volume > 100) {
new_volume = 100;
}
- } else if (event.data.down) {
- new_volume = App.info.volume - event.data.down;
+ } else if (event.data.down && (App.volume != null)) {
+ new_volume = App.volume - event.data.down;
if (new_volume < 0) {
new_volume = 0;
}
@@ -687,8 +690,8 @@ sub _cmus_parse_info {
return;
}
return App._change_valume_tid = window.setTimeout(function() {
- if ((new_volume != null) && new_volume !== App.info.volume) {
- App.info.volume = new_volume;
+ if ((new_volume != null) && new_volume !== App.volume) {
+ App.volume = new_volume;
$("#volume_slider").val(new_volume);
return $.post('/set_volume', {
volume: new_volume
View
17 src/radio-box-client.coffee
@@ -34,6 +34,7 @@ window.App =
update_info: ->
$.get '/get_info', (info_data) ->
App.info = info_data.info
+ App.volume = App.info.volume if App.info.volume?
App.render_info()
# ...........................................
@@ -82,8 +83,8 @@ window.App =
else
App.do_get_radio()
- if App.info.volume?
- $('input#volume_slider').val(App.info.volume)
+ if App.volume?
+ $('input#volume_slider').val(App.volume)
# ...........................................
render_select_radio: ->
@@ -167,11 +168,11 @@ window.App =
App._change_valume_tid = undefined
new_volume = 0
- if event.data.up
- new_volume = App.info.volume + event.data.up
+ if event.data.up && App.volume?
+ new_volume = App.volume + event.data.up
new_volume = 100 if new_volume > 100
- else if event.data.down
- new_volume = App.info.volume - event.data.down
+ else if event.data.down && App.volume?
+ new_volume = App.volume - event.data.down
new_volume = 0 if new_volume < 0
else if event.data.absolute
new_volume = parseInt($("#volume_slider").val())
@@ -180,8 +181,8 @@ window.App =
App._change_valume_tid = window.setTimeout(
() ->
- if new_volume? && new_volume != App.info.volume
- App.info.volume = new_volume
+ if new_volume? && new_volume != App.volume
+ App.volume = new_volume
$("#volume_slider").val(new_volume)
$.post '/set_volume'
volume: new_volume

0 comments on commit 4b27a35

Please sign in to comment.
Something went wrong with that request. Please try again.