]> kaliko git repositories - python-musicpd.git/blob - doc/source/examples.rst
Releasing 0.9.0
[python-musicpd.git] / doc / source / examples.rst
1 .. SPDX-FileCopyrightText: 2018-2023 kaliko <kaliko@azylum.org>
2 .. SPDX-License-Identifier: LGPL-3.0-or-later
3
4 .. _examples:
5
6 Examples
7 ========
8
9 Plain examples
10 --------------
11
12 Connect, if playing, get currently playing track, the next one:
13
14 .. literalinclude:: examples/connect.py
15    :language: python
16    :linenos:
17
18 Connect a specific password protected host:
19
20 .. literalinclude:: examples/connect_host.py
21    :language: python
22    :linenos:
23
24 Start playing current queue and set the volume:
25
26 .. literalinclude:: examples/playback.py
27    :language: python
28    :linenos:
29
30 Clear the queue, search artist, queue what's found and play:
31
32 .. literalinclude:: examples/findadd.py
33    :language: python
34    :linenos:
35
36 Object Oriented example
37 -----------------------
38
39 A plain client monitoring changes on MPD.
40
41 .. literalinclude:: examples/client.py
42    :language: python
43    :linenos:
44
45 .. _exceptions_example:
46
47 Dealing with Exceptions
48 -----------------------
49
50 Musicpd module will raise it's own :py:obj:`MPDError<musicpd.MPDError>`
51 exceptions **and** python :py:obj:`OSError`. Then you can wrap
52 :py:obj:`OSError` in :py:obj:`MPDError<musicpd.MPDError>` exceptions to have to deal
53 with a single type of exceptions in your code:
54
55 .. literalinclude:: examples/exceptions.py
56    :language: python
57    :linenos: