Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout de l'url des la pochette du disque en cours de lecture + du nom de l'album #98

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions core/class/googlecast.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions resources/googlecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
}
Expand Down