diff --git a/core/class/googlecast.class.php b/core/class/googlecast.class.php index f403798..94d9cba 100644 --- a/core/class/googlecast.class.php +++ b/core/class/googlecast.class.php @@ -186,12 +186,18 @@ public function postSave() { } */ + + public function preSave() { + $this->setGenericType('Multimedia'); + } + //public function postInsert() { public function postSave() { if ($this->_lightsave == true) { return true; } + $order = 1; $cmd = $this->getCmd(null, 'refresh'); @@ -232,6 +238,7 @@ public function postSave() $cmd->setType('info'); $cmd->setSubType('binary'); $cmd->setEqLogic_id($this->getId()); + $cmd->setGeneric_type('MEDIA_STATE'); $cmd->setDisplay('generic_type', 'ENERGY_STATE'); $cmd->save(); @@ -269,9 +276,8 @@ public function postSave() $cmd->setTemplate('dashboard', 'googlecast_busy'); $cmd->setType('info'); $cmd->setSubType('binary'); - $cmd->setEqLogic_id($this->getId()); - $cmd->setDisplay('generic_type', 'ENERGY_STATE'); + $cmd->setGeneric_type('MEDIA_STATE'); $cmd->save(); $cmd = $this->getCmd(null, 'volume_level'); @@ -442,6 +448,34 @@ public function postSave() //$cmd->setDisplay('generic_type', 'GENERIC'); $cmd->save(); + $cmd = $this->getCmd(null, 'image'); + if (!is_object($cmd)) { + $cmd = new googlecastCmd(); + $cmd->setLogicalId('image'); + $cmd->setIsVisible(0); + $cmd->setName(__('Image', __FILE__)); + $cmd->setConfiguration('googlecast_cmd', true); + $cmd->setOrder($order++); + } + $cmd->setType('info'); + $cmd->setSubType('string'); + $cmd->setEqLogic_id($this->getId()); + $cmd->save(); + + $cmd = $this->getCmd(null, 'album_name'); + if (!is_object($cmd)) { + $cmd = new googlecastCmd(); + $cmd->setLogicalId('album_name'); + $cmd->setIsVisible(0); + $cmd->setName(__('Nom album', __FILE__)); + $cmd->setConfiguration('googlecast_cmd', true); + $cmd->setOrder($order++); + } + $cmd->setType('info'); + $cmd->setSubType('string'); + $cmd->setEqLogic_id($this->getId()); + $cmd->save(); + $cmd = $this->getCmd(null, 'title'); if (!is_object($cmd)) { $cmd = new googlecastCmd(); diff --git a/resources/googlecast.py b/resources/googlecast.py index 1f228a4..1eddeb5 100644 --- a/resources/googlecast.py +++ b/resources/googlecast.py @@ -523,6 +523,10 @@ def _internal_get_status(self): if self.gcast.status is not None and self.online is True: uuid = self.uuid playStatus = self.gcast.media_controller.status + if len(playStatus.images) > 0: + img = str(playStatus.images[0].url) + else: + img = "" status = { "uuid": uuid, "uri": self.gcast.uri, "friendly_name": self.gcast.cast_info.friendly_name, @@ -536,6 +540,8 @@ def _internal_get_status(self): "status_text": self.gcast.status.status_text if self.gcast.status.status_text != "" else globals.DEFAULT_NOSTATUS, "is_busy": not self.gcast.is_idle, "title": "" if playStatus.title is None else playStatus.title, + "album_name": "" if playStatus.album_name is None else playStatus.album_name, + "image": img, "artist": "" if playStatus.artist is None else playStatus.artist, "series_title": "" if playStatus.series_title is None else playStatus.series_title, "stream_type": "" if playStatus.stream_type is None else playStatus.stream_type, @@ -582,10 +588,16 @@ def _internal_send_now_playing_statusupdate(self, new_nowplaying): test_dif = True if test_dif is True: + if len(new_nowplaying.images) > 0: + img = str(new_nowplaying.images[0].url) + else: + img = "" mediastatus = { "uuid": self.uuid, "title": '' if new_nowplaying.title is None else new_nowplaying.title, "artist": '' if new_nowplaying.artist is None else new_nowplaying.artist, + "album_name": '' if new_nowplaying.album_name is None else new_nowplaying.album_name, + "image": img, "series_title": '' if new_nowplaying.series_title is None else new_nowplaying.series_title, "player_state": '' if new_nowplaying.player_state is None else new_nowplaying.player_state, }