librmpd 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,347 @@
1
+ - &songs
2
+ - &song1
3
+ file: "Shpongle/Are_You_Shpongled/1.Shpongle_Falls.ogg"
4
+ time: 514
5
+ artist: "Shpongle"
6
+ album: "Are You Shpongled?"
7
+ title: "Shpongle Falls"
8
+ track: 1
9
+ - &song2
10
+ file: "Shpongle/Are_You_Shpongled/2.Monster_Hit.ogg"
11
+ time: 537
12
+ artist: "Shpongle"
13
+ album: "Are You Shpongled?"
14
+ title: "Monster Hit"
15
+ track: 2
16
+ - &song3
17
+ file: "Shpongle/Are_You_Shpongled/3.Vapour_Rumours.ogg"
18
+ time: 626
19
+ artist: "Shpongle"
20
+ album: "Are You Shpongled?"
21
+ title: "Vapour Rumours"
22
+ track: 3
23
+ - &song4
24
+ file: "Shpongle/Are_You_Shpongled/4.Shpongle_Spores.ogg"
25
+ time: 436
26
+ artist: "Shpongle"
27
+ album: "Are You Shpongled?"
28
+ title: "Shpongle Spores"
29
+ track: 4
30
+ - &song5
31
+ file: "Shpongle/Are_You_Shpongled/5.Behind_Closed_Eyelids.ogg"
32
+ time: 749
33
+ artist: "Shpongle"
34
+ album: "Are You Shpongled?"
35
+ title: "Behind Closed Eyelids"
36
+ track: 5
37
+ - &song6
38
+ file: "Shpongle/Are_You_Shpongled/6.Divine_Moments_of_Truth.ogg"
39
+ time: 620
40
+ artist: "Shpongle"
41
+ album: "Are You Shpongled?"
42
+ title: "Divine Moments of Truth"
43
+ track: 6
44
+ - &song7
45
+ file: "Shpongle/Are_You_Shpongled/7...._and_the_Day_Turned_to_Night.ogg"
46
+ time: 1198
47
+ artist: "Shpongle"
48
+ album: "Are You Shpongled?"
49
+ title: "... and the Day Turned to Night"
50
+ track: 7
51
+ - &song8
52
+ file: "Astral_Projection/Dancing_Galaxy/1.Dancing_Galaxy.ogg"
53
+ time: 558
54
+ artist: "Astral Projection"
55
+ album: "Dancing Galaxy"
56
+ title: "Dancing Galaxy"
57
+ track: 1
58
+ - &song9
59
+ file: "Astral_Projection/Dancing_Galaxy/2.Soundform.ogg"
60
+ time: 492
61
+ artist: "Astral Projection"
62
+ album: "Dancing Galaxy"
63
+ title: "Soundform"
64
+ track: 2
65
+ - &song10
66
+ file: "Astral_Projection/Dancing_Galaxy/3.Flying_Into_A_Star.ogg"
67
+ time: 585
68
+ artist: "Astral Projection"
69
+ album: "Dancing Galaxy"
70
+ title: "Flying Into A Star"
71
+ track: 3
72
+ - &song11
73
+ file: "Astral_Projection/Dancing_Galaxy/4.No_One_Ever_Dreams.ogg"
74
+ time: 505
75
+ artist: "Astral Projection"
76
+ album: "Dancing Galaxy"
77
+ title: "No One Ever Dreams"
78
+ track: 4
79
+ - &song12
80
+ file: "Astral_Projection/Dancing_Galaxy/5.Cosmic_Ascension_(ft._DJ_Jorg).ogg"
81
+ time: 619
82
+ artist: "Astral Projection"
83
+ album: "Dancing Galaxy"
84
+ title: "Cosmic Ascension (ft. DJ Jorg)"
85
+ track: 5
86
+ - &song13
87
+ file: "Astral_Projection/Dancing_Galaxy/6.Life_On_Mars.ogg"
88
+ time: 549
89
+ artist: "Astral Projection"
90
+ album: "Dancing Galaxy"
91
+ title: "Life On Mars"
92
+ track: 6
93
+ - &song14
94
+ file: "Astral_Projection/Dancing_Galaxy/7.Liquid_Sun.ogg"
95
+ time: 660
96
+ artist: "Astral Projection"
97
+ album: "Dancing Galaxy"
98
+ title: "Liquid Sun"
99
+ track: 7
100
+ - &song15
101
+ file: "Astral_Projection/Dancing_Galaxy/8.Ambient_Galaxy_(Disco_Valley_Mix).ogg"
102
+ time: 825
103
+ artist: "Astral Projection"
104
+ album: "Dancing Galaxy"
105
+ title: "Ambient Galaxy (Disco Valley Mix)"
106
+ track: 8
107
+ - &song16
108
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/01.Central_Plains.ogg"
109
+ time: 488
110
+ artist: "Carbon Based Lifeforms"
111
+ album: "Hydroponic Garden"
112
+ title: "Central Plains"
113
+ track: 1
114
+ - &song17
115
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/02.Tensor.ogg"
116
+ time: 344
117
+ artist: "Carbon Based Lifeforms"
118
+ album: "Hydroponic Garden"
119
+ title: "Tensor"
120
+ track: 2
121
+ - &song18
122
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/03.MOS_6581_(Album_Version).ogg"
123
+ time: 431
124
+ artist: "Carbon Based Lifeforms"
125
+ album: "Hydroponic Garden"
126
+ title: "MOS 6581 (Album Version)"
127
+ track: 3
128
+ - &song19
129
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/04.Silent_Running.ogg"
130
+ time: 425
131
+ artist: "Carbon Based Lifeforms"
132
+ album: "Hydroponic Garden"
133
+ title: "Silent Running"
134
+ track: 4
135
+ - &song20
136
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/05.Neurotransmitter.ogg"
137
+ time: 448
138
+ artist: "Carbon Based Lifeforms"
139
+ album: "Hydroponic Garden"
140
+ title: "Neurotransmitter"
141
+ track: 5
142
+ - &song21
143
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/06.Hydroponic_Garden.ogg"
144
+ time: 553
145
+ artist: "Carbon Based Lifeforms"
146
+ album: "Hydroponic Garden"
147
+ title: "Hydroponic Garden"
148
+ track: 6
149
+ - &song22
150
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/07.Exosphere.ogg"
151
+ time: 306
152
+ artist: "Carbon Based Lifeforms"
153
+ album: "Hydroponic Garden"
154
+ title: "Exosphere"
155
+ track: 7
156
+ - &song23
157
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/08.Comsat.ogg"
158
+ time: 429
159
+ artist: "Carbon Based Lifeforms"
160
+ album: "Hydroponic Garden"
161
+ title: "Comsat"
162
+ track: 8
163
+ - &song24
164
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/09.Epicentre_(First_Movement).ogg"
165
+ time: 358
166
+ artist: "Carbon Based Lifeforms"
167
+ album: "Hydroponic Garden"
168
+ title: "Epicentre (First Movement)"
169
+ track: 9
170
+ - &song25
171
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/10.Artificial_Island.ogg"
172
+ time: 312
173
+ artist: "Carbon Based Lifeforms"
174
+ album: "Hydroponic Garden"
175
+ title: "Artificial Island"
176
+ track: 10
177
+ - &song26
178
+ file: "Carbon_Based_Lifeforms/Hydroponic_Garden/11.Refraction_1.33.ogg"
179
+ time: 500
180
+ artist: "Carbon Based Lifeforms"
181
+ album: "Hydroponic Garden"
182
+ title: "Refraction 1.33"
183
+ track: 11
184
+ - &song27
185
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/01.Botanical_Dimensions.ogg"
186
+ time: 278
187
+ artist: "Shpongle"
188
+ album: "Nothing Lasts... But Nothing Is Lost"
189
+ title: "Botanical Dimensions"
190
+ track: 1
191
+ - &song28
192
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/02.Outer_Shpongolia.ogg"
193
+ time: 153
194
+ artist: "Shpongle"
195
+ album: "Nothing Lasts... But Nothing Is Lost"
196
+ title: "Outer Shpongolia"
197
+ track: 2
198
+ - &song29
199
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/03.Levitation_Nation.ogg"
200
+ time: 220
201
+ artist: "Shpongle"
202
+ album: "Nothing Lasts... But Nothing Is Lost"
203
+ title: "Levitation Nation"
204
+ track: 3
205
+ - &song30
206
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/04.Periscopes_of_Consciousness.ogg"
207
+ time: 114
208
+ artist: "Shpongle"
209
+ album: "Nothing Lasts... But Nothing Is Lost"
210
+ title: "Periscopes of Consciousness"
211
+ track: 4
212
+ - &song31
213
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/05.Schmaltz_Herring.ogg"
214
+ time: 141
215
+ artist: "Shpongle"
216
+ album: "Nothing Lasts... But Nothing Is Lost"
217
+ title: "Schmaltz Herring"
218
+ track: 5
219
+ - &song32
220
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/06.Nothing_Lasts....ogg"
221
+ time: 269
222
+ artist: "Shpongle"
223
+ album: "Nothing Lasts... But Nothing Is Lost"
224
+ title: "Nothing Lasts..."
225
+ track: 6
226
+ - &song33
227
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/07.Shnitzled_in_the_Negev.ogg"
228
+ time: 258
229
+ artist: "Shpongle"
230
+ album: "Nothing Lasts... But Nothing Is Lost"
231
+ title: "Shnitzled in the Negev"
232
+ track: 7
233
+ - &song34
234
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/08....But_Nothing_Is_Lost.ogg"
235
+ time: 279
236
+ artist: "Shpongle"
237
+ album: "Nothing Lasts... But Nothing Is Lost"
238
+ title: "...But Nothing Is Lost"
239
+ track: 8
240
+ - &song35
241
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/09.When_Shall_I_Be_Free.ogg"
242
+ time: 277
243
+ artist: "Shpongle"
244
+ album: "Nothing Lasts... But Nothing Is Lost"
245
+ title: "When Shall I Be Free"
246
+ track: 9
247
+ - &song36
248
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/10.The_Stamen_of_the_Shamen.ogg"
249
+ time: 251
250
+ artist: "Shpongle"
251
+ album: "Nothing Lasts... But Nothing Is Lost"
252
+ title: "The Stamen of the Shamen"
253
+ track: 10
254
+ - &song37
255
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/11.Circuits_of_the_Imagination.ogg"
256
+ time: 192
257
+ artist: "Shpongle"
258
+ album: "Nothing Lasts... But Nothing Is Lost"
259
+ title: "Circuits of the Imagination"
260
+ track: 11
261
+ - &song38
262
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/12.Linguistic_Mystic.ogg"
263
+ time: 96
264
+ artist: "Shpongle"
265
+ album: "Nothing Lasts... But Nothing Is Lost"
266
+ title: "Linguistic Mystic"
267
+ track: 12
268
+ - &song39
269
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/13.Mentalism.ogg"
270
+ time: 174
271
+ artist: "Shpongle"
272
+ album: "Nothing Lasts... But Nothing Is Lost"
273
+ title: "Mentalism"
274
+ track: 13
275
+ - &song40
276
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/14.Invocation.ogg"
277
+ time: 160
278
+ artist: "Shpongle"
279
+ album: "Nothing Lasts... But Nothing Is Lost"
280
+ title: "Invocation"
281
+ track: 14
282
+ - &song41
283
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/15.Molecular_Superstructure.ogg"
284
+ time: 287
285
+ artist: "Shpongle"
286
+ album: "Nothing Lasts... But Nothing Is Lost"
287
+ title: "Molecular Superstructure"
288
+ track: 15
289
+ - &song42
290
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/16.Turn_Up_the_Silence.ogg"
291
+ time: 202
292
+ artist: "Shpongle"
293
+ album: "Nothing Lasts... But Nothing Is Lost"
294
+ title: "Turn Up the Silence"
295
+ track: 16
296
+ - &song43
297
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/17.Exhalation.ogg"
298
+ time: 136
299
+ artist: "Shpongle"
300
+ album: "Nothing Lasts... But Nothing Is Lost"
301
+ title: "Exhalation"
302
+ track: 17
303
+ - &song44
304
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/18.Connoisseur_of_Hallucinations.ogg"
305
+ time: 212
306
+ artist: "Shpongle"
307
+ album: "Nothing Lasts... But Nothing Is Lost"
308
+ title: "Connoisseur of Hallucinations"
309
+ track: 18
310
+ - &song45
311
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/19.The_Nebbish_Route.ogg"
312
+ time: 215
313
+ artist: "Shpongle"
314
+ album: "Nothing Lasts... But Nothing Is Lost"
315
+ title: "The Nebbish Route"
316
+ track: 19
317
+ - &song46
318
+ file: "Shpongle/Nothing_Lasts..._But_Nothing_Is_Lost/20.Falling_Awake.ogg"
319
+ time: 110
320
+ artist: "Shpongle"
321
+ album: "Nothing Lasts... But Nothing Is Lost"
322
+ title: "Falling Awake"
323
+ track: 20
324
+
325
+ - &playlists
326
+ - &playlist1
327
+ file: "Shpongle_-_Are_You_Shpongled.m3u"
328
+ songs:
329
+ - *song1
330
+ - *song2
331
+ - *song3
332
+ - *song4
333
+ - *song5
334
+ - *song6
335
+ - *song7
336
+ - &playlist2
337
+ file: "Astral_Projection_-_Dancing_Galaxy.m3u"
338
+ songs:
339
+ - *song8
340
+ - *song9
341
+ - *song10
342
+ - *song11
343
+ - *song12
344
+ - *song13
345
+ - *song14
346
+ - *song15
347
+
data/examples/rmpc.rb ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ # This is a very simple MPD client that just sends commands to the server
4
+ # from the command line
5
+ #
6
+ # Copyright 2006 Andrew Rader ( bitwise_mcgee AT yahoo.com | http://nymb.us )
7
+ #
8
+
9
+ require 'rubygems'
10
+ require 'librmpd'
11
+ require 'thread'
12
+
13
+ if ARGV.length == 0
14
+ puts "Usage: rmpc.rb <command> <command options>"
15
+ puts "\tUse --help for commands / command options"
16
+
17
+ else
18
+ if ARGV.include?( '--help' ) or ARGV.include?( '-h' )
19
+ puts "Usage: rmpc.rb <command> <command options>"
20
+ puts "\tAvailable Commands / Command Options:\n\n"
21
+ puts "\tcmd\topts\tdescription"
22
+ puts "\tplay\t[pos]\tbegin playback, optionally play song at position pos"
23
+ puts "\tpause\tnone\ttoggle the pause flag"
24
+ puts "\tstop\tnone\tstop playback"
25
+ puts "\tnext\tnone\tplay next in playlist"
26
+ puts "\tprev\tnone\tplay previous in playlist"
27
+ puts "\tvolume\t[vol]\tprint the current volume, or, sets the volume to vol"
28
+ puts "\trepeat\tnone\ttoggle the repeat flag"
29
+ puts "\trandom\tnone\ttoggle the random flag"
30
+ puts "\tstats\tnone\tprint the server stats"
31
+ else
32
+ mpd = MPD.new
33
+ mpd.connect
34
+ case ARGV[0]
35
+ when 'play'
36
+ mpd.play ARGV[1]
37
+ when 'pause'
38
+ mpd.pause = !mpd.paused?
39
+ when 'stop'
40
+ mpd.stop
41
+ when 'next'
42
+ mpd.next
43
+ when 'prev'
44
+ mpd.previous
45
+ when 'volume'
46
+ if ARGV[1].nil?
47
+ puts "Volume: #{mpd.volume}"
48
+ else
49
+ mpd.volume = ARGV[1].to_i
50
+ end
51
+ when 'repeat'
52
+ mpd.repeat = !mpd.repeat?
53
+ when 'random'
54
+ mpd.random = !mpd.random?
55
+ when 'stats'
56
+ hash = mpd.stats
57
+ hash.each_pair do |key, value|
58
+ puts "#{key} => #{value}"
59
+ end
60
+ else
61
+ puts "Unknown Command #{ARGV[0]}"
62
+ end
63
+ mpd.disconnect
64
+ end
65
+ end
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ #
4
+ # This is a very simple MPD client that just spews changes on the server
5
+ # out to the console (much like tail works on normal files)
6
+ #
7
+ # Copyright 2006 Andrew Rader ( bitwise_mcgee AT yahoo.com | http://nymb.us )
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'librmpd'
12
+ require 'thread'
13
+
14
+ class TailMPC
15
+
16
+ def initialize( time_cb = false )
17
+ @mpd = MPD.new
18
+
19
+ @mpd.register_callback( self.method('playlist_cb'), MPD::PLAYLIST_CALLBACK )
20
+ @mpd.register_callback( self.method('song_cb'), MPD::CURRENT_SONG_CALLBACK )
21
+ @mpd.register_callback( self.method('state_cb'), MPD::STATE_CALLBACK )
22
+ @mpd.register_callback( self.method('time_cb'), MPD::TIME_CALLBACK ) if time_cb
23
+ @mpd.register_callback( self.method('vol_cb'), MPD::VOLUME_CALLBACK )
24
+ @mpd.register_callback( self.method('repeat_cb'), MPD::REPEAT_CALLBACK )
25
+ @mpd.register_callback( self.method('random_cb'), MPD::RANDOM_CALLBACK )
26
+ @mpd.register_callback( self.method('pls_length_cb'), MPD::PLAYLIST_LENGTH_CALLBACK )
27
+ @mpd.register_callback( self.method('xfade_cb'), MPD::CROSSFADE_CALLBACK )
28
+ @mpd.register_callback( self.method('songid_cb'), MPD::CURRENT_SONGID_CALLBACK )
29
+ @mpd.register_callback( self.method('bitrate_cb'), MPD::BITRATE_CALLBACK )
30
+ @mpd.register_callback( self.method('audio_cb'), MPD::AUDIO_CALLBACK )
31
+ @mpd.register_callback( self.method('connection_cb'), MPD::CONNECTION_CALLBACK )
32
+ end
33
+
34
+ def start
35
+ puts "Starting TailMPC - Press Ctrl-D to quit\n\n"
36
+ @mpd.connect true
37
+ t = Thread.new do
38
+ gets
39
+ end
40
+
41
+ t.join
42
+ end
43
+
44
+ def stop
45
+ puts "Shutting Down TailMPC"
46
+ @mpd.disconnect true
47
+ end
48
+
49
+ def time_cb( elapsed, total )
50
+ el_min = elapsed / 60
51
+ el_sec = elapsed % 60
52
+
53
+ elapsed = "#{el_min}:#{el_sec}"
54
+
55
+ tot_min = total / 60
56
+ tot_sec = total % 60
57
+
58
+ total = "#{tot_min}:#{tot_sec}"
59
+ puts "Time: #{elapsed} / #{total}"
60
+ end
61
+
62
+ def state_cb( newstate )
63
+ puts "State: #{newstate}"
64
+ end
65
+
66
+ def song_cb( current )
67
+ if not current.nil?
68
+ puts "Current Song: \n\tID: #{current.songid}\n\tPosition: #{current.pos}\n\tFile: #{current.file}\n\tArtist: #{current.artist}\n\tTitle: #{current.title}"
69
+ else
70
+ puts "Curent Song: nil"
71
+ end
72
+ end
73
+
74
+ def playlist_cb( pls )
75
+ puts "Playlist: Version ##{pls}"
76
+ end
77
+
78
+ def vol_cb( vol )
79
+ puts "Volume: #{vol}%"
80
+ end
81
+
82
+ def repeat_cb( rep )
83
+ puts(rep ? 'Repeat: On' : 'Repeat: Off')
84
+ end
85
+
86
+ def random_cb( ran )
87
+ puts(ran ? 'Random: On' : 'Random: Off')
88
+ end
89
+
90
+ def pls_length_cb( len )
91
+ puts "Playlist Length: #{len}"
92
+ end
93
+
94
+ def xfade_cb( xfade )
95
+ puts "Crossfade: #{xfade}"
96
+ end
97
+
98
+ def songid_cb( id )
99
+ puts "Current Song ID: #{id}"
100
+ end
101
+
102
+ def bitrate_cb( rate )
103
+ puts "Bitrate: #{rate}"
104
+ end
105
+
106
+ def audio_cb( sample, bits, channels )
107
+ puts "Audio:\n\tSample Rate: #{sample}\n\tBits: #{bits}\n\tChannels: #{channels}"
108
+ end
109
+
110
+ def connection_cb( connected )
111
+ puts( connected ? 'Connected' : 'Disconnected' )
112
+ end
113
+ end
114
+
115
+ client = TailMPC.new #true # Uncomment the true to enable the time callback
116
+
117
+ client.start