From 025309cae8ac8c6836e22f986bb0d2c0c7bf0d42 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 13 Nov 2018 23:17:51 +0100 Subject: [PATCH] Fixed Chromecast media_controller methods --- platypush/plugins/media/chromecast.py | 29 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/platypush/plugins/media/chromecast.py b/platypush/plugins/media/chromecast.py index 995302288a..25fb6df294 100644 --- a/platypush/plugins/media/chromecast.py +++ b/platypush/plugins/media/chromecast.py @@ -180,52 +180,61 @@ class MediaChromecastPlugin(Plugin): @action def play(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).play() + return self.get_chromecast(chromecast or self.chromecast).media_controller.play() @action def pause(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).pause() + return self.get_chromecast(chromecast or self.chromecast).media_controller.pause() + + + @action + def toggle_pause(self, chromecast=None): + cast = self.get_chromecast(chromecast or self.chromecast) + if cast.media_controller.is_paused: + return cast.media_controller.play() + else: + return cast.media_controller.pause() @action def stop(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).stop() + return self.get_chromecast(chromecast or self.chromecast).media_controller.stop() @action def rewind(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).rewind() + return self.get_chromecast(chromecast or self.chromecast).media_controller.rewind() @action def seek(self, location, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).seek(location) + return self.get_chromecast(chromecast or self.chromecast).media_controller.seek(location) @action def is_playing(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).is_playing + return self.get_chromecast(chromecast or self.chromecast).media_controller.is_playing @action def is_paused(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).is_paused + return self.get_chromecast(chromecast or self.chromecast).media_controller.is_paused @action def enable_subtitle(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).enable_subtitle + return self.get_chromecast(chromecast or self.chromecast).media_controller.enable_subtitle() @action def disable_subtitle(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).disable_subtitle + return self.get_chromecast(chromecast or self.chromecast).media_controller.disable_subtitle() @action def status(self, chromecast=None): - return self.get_chromecast(chromecast or self.chromecast).status + return self.get_chromecast(chromecast or self.chromecast).media_controller.status @action