Turn off source player when swicthing media

This commit is contained in:
estevez-dev 2019-09-15 17:38:29 +03:00
parent 340e8569cc
commit 72aad5cc16

View File

@ -33,7 +33,8 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
}); });
} }
void _sendTo(entity) { void _switchTo(entity) {
eventBus.fire(ServiceCallEvent("media_player", "turn_off", entity.entityId, null));
HomeAssistant().savedPlayerPosition = entity.getActualPosition().toInt(); HomeAssistant().savedPlayerPosition = entity.getActualPosition().toInt();
HomeAssistant().savedPlayerId = entity.entityId; HomeAssistant().savedPlayerId = entity.entityId;
Navigator.of(context).pushNamed("/play-media", arguments: {"url": entity.attributes["media_content_id"], "type": entity.attributes["media_content_type"]}); Navigator.of(context).pushNamed("/play-media", arguments: {"url": entity.attributes["media_content_id"], "type": entity.attributes["media_content_type"]});
@ -78,10 +79,10 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
} }
buttons.add( buttons.add(
RaisedButton( RaisedButton(
child: Text("Send to another player..."), child: Text("Switch to..."),
color: Colors.blue, color: Colors.blue,
textColor: Colors.white, textColor: Colors.white,
onPressed: () => _sendTo(entity), onPressed: () => _switchTo(entity),
) )
); );
return Padding( return Padding(