File: Moosic_API.sect0.pod

package info (click to toggle)
moosic 1.5.4-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 840 kB
  • ctags: 586
  • sloc: python: 3,360; makefile: 40
file content (72 lines) | stat: -rw-r--r-- 2,232 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
=head1 Section 0: Instructions for Impatient Developers

=over

=item 1.

Plan to write your program with Python and xmlrpclib. xmlrpclib is included with
Python 2.2 or later, but if you need to use an earlier version of Python,
xmlrpclib can be downloaded from L<http://www.pythonware.com/products/xmlrpc/>.

=item 2.

If you can't or don't want to write your program with Python and xmlrpclib, you
won't benefit from this section and will have to read section 2 of this
document.

=item 3.

Create a proxy which communicates with moosicd:

   >>> import moosic.client.factory
   >>> proxy = moosic.client.factory.LocalMoosicProxy()

=item 4.

Read section 3 for the documentation of all the methods supported by the proxy
object.

=item 5.

Use the proxy to get information from the server and to send commands to it.
For example:

   >>> proxy.list()
   []
   >>> proxy.is_queue_running()
   True
   >>> proxy.haltqueue()
   True
   >>> proxy.is_queue_running()
   False
   >>> proxy.append([xmlrpc.Binary(i) for i in 
   ...       ['/home/daniel/music/Weird_Al/Pretty_Fly_for_a_Rabbi.mp3',
   ...        '/home/daniel/music/Fiona_Apple/When_The_Pawn/04-Love_Ridden.ogg',
   ...        "/home/daniel/music/Zelda/Great_Fairy's_Fountain.mid"]])
   True
   >>> proxy.list()
   [<xmlrpclib.Binary instance at 0x843cf3c>,
    <xmlrpclib.Binary instance at 0x8440e94>,
    <xmlrpclib.Binary instance at 0x8440ebc>]
   >>> [i.data for i in proxy.list()]
   ['/home/daniel/music/Weird_Al/Pretty_Fly_for_a_Rabbi.mp3',
    '/home/daniel/music/Fiona_Apple/When_The_Pawn/04-Love_Ridden.ogg',
    "/home/daniel/music/Zelda/Great_Fairy's_Fountain.mid"]
   >>> proxy.sort()
   True
   >>> [i.data for i in proxy.list()]
   ['/home/daniel/music/Fiona_Apple/When_The_Pawn/04-Love_Ridden.ogg',
    '/home/daniel/music/Weird_Al/Pretty_Fly_for_a_Rabbi.mp3',
    "/home/daniel/music/Zelda/Great_Fairy's_Fountain.mid"]

=item 6.

If you wish to communicate with a moosicd that is listening for requests on
an IP socket instead of a Unix domain socket, you should use InetMoosicProxy
instead of LocalMoosicProxy.  Here's an example:

   >>> import moosic.client.factory
   >>> proxy = moosic.client.factory.InetMoosicProxy('example.com', 8080)

=back