summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2012-11-27 21:22:06 +0100
committerLaurent Bachelier <laurent@bachelier.name>2012-11-27 21:22:06 +0100
commit5bdae5fb05af69f3cc53db1aa087a4c8d2814893 (patch)
tree8314bc00b2bb7b933ac47f61598e65f18e352cc3
parentPEP8 compliance (diff)
downloadmpdat-5bdae5fb05af69f3cc53db1aa087a4c8d2814893.tar.xz
Add single_stop()
-rw-r--r--mpdat/client.py7
-rwxr-xr-xsstop_example.py11
2 files changed, 18 insertions, 0 deletions
diff --git a/mpdat/client.py b/mpdat/client.py
index ef27871..37a91e1 100644
--- a/mpdat/client.py
+++ b/mpdat/client.py
@@ -122,3 +122,10 @@ class MPDatClient(mpd.MPDClient):
self.delete(pos)
except mpd.CommandError:
pass
+
+ def single_stop(self):
+ self.single(1)
+ while self.status()['state'] != 'pause':
+ time.sleep(1)
+ self.single(0)
+ self.stop()
diff --git a/sstop_example.py b/sstop_example.py
new file mode 100755
index 0000000..68a38cd
--- /dev/null
+++ b/sstop_example.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+from mpdat import MPDatClient
+from os import environ
+
+mpd_host = environ.get("MPD_HOST", "localhost")
+mpd_port = environ.get("MPD_PORT", 6600)
+
+m = MPDatClient()
+m.connect_from_env(mpd_host, mpd_port)
+
+m.single_stop()