From 2f07ffc4e46cf378b24b684117e21c4a9db2c6ca Mon Sep 17 00:00:00 2001 From: jodur Date: Thu, 1 Feb 2018 09:49:39 +0100 Subject: [PATCH] added media_stop (#12100) * added media_stop VLC was missing the media_stop. The pause was present, but starting the same file result in resuming the file instead of start over new * Corrected style issues Style issues and added Support Flag to Support VLC * fixed other style issues * remove trailing whitespace --- homeassistant/components/media_player/vlc.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/media_player/vlc.py b/homeassistant/components/media_player/vlc.py index d3346495015..abd8252d813 100644 --- a/homeassistant/components/media_player/vlc.py +++ b/homeassistant/components/media_player/vlc.py @@ -9,8 +9,10 @@ import logging import voluptuous as vol from homeassistant.components.media_player import ( - SUPPORT_PAUSE, SUPPORT_PLAY_MEDIA, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, - SUPPORT_PLAY, MediaPlayerDevice, PLATFORM_SCHEMA, MEDIA_TYPE_MUSIC) + SUPPORT_PAUSE, SUPPORT_PLAY_MEDIA, SUPPORT_STOP, SUPPORT_VOLUME_MUTE, + SUPPORT_VOLUME_SET, SUPPORT_PLAY, MediaPlayerDevice, PLATFORM_SCHEMA, + MEDIA_TYPE_MUSIC) + from homeassistant.const import (CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING) import homeassistant.helpers.config_validation as cv @@ -24,7 +26,7 @@ CONF_ARGUMENTS = 'arguments' DEFAULT_NAME = 'Vlc' SUPPORT_VLC = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ - SUPPORT_PLAY_MEDIA | SUPPORT_PLAY + SUPPORT_PLAY_MEDIA | SUPPORT_PLAY | SUPPORT_STOP PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, @@ -146,6 +148,11 @@ class VlcDevice(MediaPlayerDevice): self._vlc.pause() self._state = STATE_PAUSED + def media_stop(self): + """Send stop command.""" + self._vlc.stop() + self._state = STATE_IDLE + def play_media(self, media_type, media_id, **kwargs): """Play media from a URL or file.""" if not media_type == MEDIA_TYPE_MUSIC: