File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,16 @@ def initialize(speaker, track)
19
19
def save_state
20
20
puts 'Saving speaker state'
21
21
speaker . pause if @was_playing = playing?
22
+ speaker . unmute if @was_muted = speaker . muted?
23
+ @previous_volume = speaker . volume
22
24
@previous = speaker . now_playing
23
25
end
24
26
25
27
def play ( track )
26
28
puts "Playing track #{ track } on speaker #{ speaker . name } "
27
29
30
+ speaker . volume = rand ( 15 )
31
+
28
32
# queue up the track
29
33
speaker . play track
30
34
@@ -43,6 +47,9 @@ def restore_state
43
47
if @previous
44
48
speaker . select_track @previous [ :queue_position ]
45
49
speaker . seek Time . parse ( "1/1/1970 #{ @previous [ :current_position ] } -0000" ) . to_i
50
+
51
+ speaker . volume = @previous_volume
52
+ speaker . mute if @was_muted
46
53
end
47
54
48
55
speaker . play if @was_playing
You can’t perform that action at this time.
0 commit comments