moc 2.5.0.1 → 2.5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/moc/controller.rb +10 -0
- data/lib/moc/controller/player.rb +22 -2
- data/lib/moc/controller/toggle.rb +8 -0
- data/lib/moc/version.rb +1 -1
- metadata +1 -1
data/lib/moc/controller.rb
CHANGED
@@ -51,6 +51,8 @@ class Controller
|
|
51
51
|
|
52
52
|
def send (object)
|
53
53
|
@socket.write object.respond_to?(:pack) ? object.pack : object.to_s
|
54
|
+
|
55
|
+
self
|
54
56
|
end
|
55
57
|
|
56
58
|
def send_command (command)
|
@@ -170,6 +172,8 @@ class Controller
|
|
170
172
|
|
171
173
|
def on (event = nil, &block)
|
172
174
|
@events[event ? nil : event.to_sym.upcase] << block
|
175
|
+
|
176
|
+
self
|
173
177
|
end
|
174
178
|
|
175
179
|
def fire (event)
|
@@ -182,12 +186,16 @@ class Controller
|
|
182
186
|
@events[name].each {|block|
|
183
187
|
block.call(event)
|
184
188
|
}
|
189
|
+
|
190
|
+
self
|
185
191
|
end
|
186
192
|
|
187
193
|
def loop
|
188
194
|
while event = read_event
|
189
195
|
fire event
|
190
196
|
end
|
197
|
+
|
198
|
+
self
|
191
199
|
end
|
192
200
|
|
193
201
|
def wait_for (name)
|
@@ -208,6 +216,8 @@ class Controller
|
|
208
216
|
|
209
217
|
def quit
|
210
218
|
send_command :quit
|
219
|
+
|
220
|
+
self
|
211
221
|
end
|
212
222
|
|
213
223
|
def toggle
|
@@ -56,6 +56,8 @@ class Player
|
|
56
56
|
while item = controller.read_item
|
57
57
|
block.call(item)
|
58
58
|
end
|
59
|
+
|
60
|
+
self
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
@@ -67,49 +69,67 @@ class Player
|
|
67
69
|
|
68
70
|
def play
|
69
71
|
controller.send_command :unpause
|
72
|
+
|
73
|
+
self
|
70
74
|
end
|
71
75
|
|
72
76
|
# pause the current song
|
73
77
|
def pause
|
74
78
|
controller.send_command :pause
|
79
|
+
|
80
|
+
self
|
75
81
|
end
|
76
82
|
|
77
83
|
# unpause the current song
|
78
84
|
def unpause
|
79
85
|
controller.send_command :unpause
|
86
|
+
|
87
|
+
self
|
80
88
|
end
|
81
89
|
|
82
90
|
# stop the current song
|
83
91
|
def stop
|
84
92
|
controller.send_command :stop
|
93
|
+
|
94
|
+
self
|
85
95
|
end
|
86
96
|
|
87
97
|
# go to the next song in the playlist
|
88
98
|
def next
|
89
99
|
controller.send_command :next
|
100
|
+
|
101
|
+
self
|
90
102
|
end
|
91
103
|
|
92
104
|
# go to the previous song in the playlist
|
93
105
|
def prev
|
94
106
|
controller.send_command :prev
|
107
|
+
|
108
|
+
self
|
95
109
|
end
|
96
110
|
|
97
111
|
# change the volume
|
98
112
|
def volume (volume)
|
99
113
|
controller.send_command :set_mixer
|
100
114
|
controller.send_integer volume
|
115
|
+
|
116
|
+
self
|
101
117
|
end
|
102
118
|
|
103
|
-
# seek
|
119
|
+
# seek of the passed seconds
|
104
120
|
def seek (second)
|
105
121
|
controller.send_command :seek
|
106
122
|
controller.send_integer second
|
123
|
+
|
124
|
+
self
|
107
125
|
end
|
108
126
|
|
109
|
-
# jump to the passed
|
127
|
+
# jump to the passed seconds
|
110
128
|
def jump_to (second)
|
111
129
|
controller.send_command :jump_to
|
112
130
|
controller.send_integer second
|
131
|
+
|
132
|
+
self
|
113
133
|
end
|
114
134
|
|
115
135
|
# return the queue
|
@@ -88,21 +88,29 @@ class Toggle
|
|
88
88
|
# toggle mixer channel
|
89
89
|
def mixer_channel
|
90
90
|
controller.send_command :toggle_mixer_channel
|
91
|
+
|
92
|
+
self
|
91
93
|
end
|
92
94
|
|
93
95
|
# toggle soft mixer
|
94
96
|
def soft_mixer
|
95
97
|
controller.send_command :toggle_softmixer
|
98
|
+
|
99
|
+
self
|
96
100
|
end
|
97
101
|
|
98
102
|
# toggle equalizer
|
99
103
|
def equalizer
|
100
104
|
controller.send_command :toggle_equalizer
|
105
|
+
|
106
|
+
self
|
101
107
|
end
|
102
108
|
|
103
109
|
# toggle mono
|
104
110
|
def mono
|
105
111
|
controller.send_command :toggle_mono
|
112
|
+
|
113
|
+
self
|
106
114
|
end
|
107
115
|
end
|
108
116
|
|
data/lib/moc/version.rb
CHANGED