From 4b7730d4cfa186727d762ed62c2b8e5bc3605c9d Mon Sep 17 00:00:00 2001
From: Fabio Manganiello <blacklight86@gmail.com>
Date: Sat, 2 Feb 2019 17:55:26 +0100
Subject: [PATCH] Added status method to mplayer plugin

---
 platypush/plugins/media/mplayer.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/platypush/plugins/media/mplayer.py b/platypush/plugins/media/mplayer.py
index 4d879f24..f774dbf0 100644
--- a/platypush/plugins/media/mplayer.py
+++ b/platypush/plugins/media/mplayer.py
@@ -329,6 +329,33 @@ class MediaMplayerPlugin(MediaPlugin):
         """
         return self._exec('volume', volume)
 
+    @action
+    def status(self):
+        """
+        Get the current player state.
+
+        :returns: A dictionary containing the current state.
+
+        Example::
+
+            output = {
+                "state": "play"  # or "stop" or "pause"
+            }
+        """
+
+        state = { 'state': PlayerState.STOP.value }
+
+        try:
+            paused = self.get_property('pause').output.get('pause')
+            if paused is True:
+                state['state'] = PlayerState.PAUSE.value
+            elif paused is False:
+                state['state'] = PlayerState.PLAY.value
+        except:
+            pass
+        finally:
+            return state
+
     @action
     def get_property(self, property, args=None):
         """