Fixed Chromecast media_controller methods

This commit is contained in:
Fabio Manganiello 2018-11-13 23:17:51 +01:00
parent 632da318b1
commit 025309cae8

View file

@ -180,52 +180,61 @@ class MediaChromecastPlugin(Plugin):
@action @action
def play(self, chromecast=None): 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 @action
def pause(self, chromecast=None): 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 @action
def stop(self, chromecast=None): 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 @action
def rewind(self, chromecast=None): 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 @action
def seek(self, location, chromecast=None): 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 @action
def is_playing(self, chromecast=None): 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 @action
def is_paused(self, chromecast=None): 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 @action
def enable_subtitle(self, chromecast=None): 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 @action
def disable_subtitle(self, chromecast=None): 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 @action
def status(self, chromecast=None): 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 @action