-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Add general sound mode support #14729
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8c91469
Media player: general sound mode support
starkillerOG 1e2cc5e
General sound mode support
starkillerOG 01196ac
White spaces
starkillerOG 6d60b5b
Add sound mode support to demo media player
starkillerOG 6b9e7c6
white space
starkillerOG 9e7dd0f
remove unnessesary code
starkillerOG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ | |
|
|
||
| SERVICE_PLAY_MEDIA = 'play_media' | ||
| SERVICE_SELECT_SOURCE = 'select_source' | ||
| SERVICE_SELECT_SOUND_MODE = 'select_sound_mode' | ||
| SERVICE_CLEAR_PLAYLIST = 'clear_playlist' | ||
|
|
||
| ATTR_MEDIA_VOLUME_LEVEL = 'volume_level' | ||
|
|
@@ -81,6 +82,8 @@ | |
| ATTR_APP_NAME = 'app_name' | ||
| ATTR_INPUT_SOURCE = 'source' | ||
| ATTR_INPUT_SOURCE_LIST = 'source_list' | ||
| ATTR_SOUND_MODE = 'sound_mode' | ||
| ATTR_SOUND_MODE_LIST = 'sound_mode_list' | ||
| ATTR_MEDIA_ENQUEUE = 'enqueue' | ||
| ATTR_MEDIA_SHUFFLE = 'shuffle' | ||
|
|
||
|
|
@@ -109,6 +112,7 @@ | |
| SUPPORT_CLEAR_PLAYLIST = 8192 | ||
| SUPPORT_PLAY = 16384 | ||
| SUPPORT_SHUFFLE_SET = 32768 | ||
| SUPPORT_SELECT_SOUND_MODE = 65536 | ||
|
|
||
| # Service call validation schemas | ||
| MEDIA_PLAYER_SCHEMA = vol.Schema({ | ||
|
|
@@ -132,6 +136,10 @@ | |
| vol.Required(ATTR_INPUT_SOURCE): cv.string, | ||
| }) | ||
|
|
||
| MEDIA_PLAYER_SELECT_SOUND_MODE_SCHEMA = MEDIA_PLAYER_SCHEMA.extend({ | ||
| vol.Required(ATTR_SOUND_MODE): cv.string, | ||
| }) | ||
|
|
||
| MEDIA_PLAYER_PLAY_MEDIA_SCHEMA = MEDIA_PLAYER_SCHEMA.extend({ | ||
| vol.Required(ATTR_MEDIA_CONTENT_TYPE): cv.string, | ||
| vol.Required(ATTR_MEDIA_CONTENT_ID): cv.string, | ||
|
|
@@ -167,6 +175,9 @@ | |
| SERVICE_SELECT_SOURCE: { | ||
| 'method': 'async_select_source', | ||
| 'schema': MEDIA_PLAYER_SELECT_SOURCE_SCHEMA}, | ||
| SERVICE_SELECT_SOUND_MODE: { | ||
| 'method': 'async_select_sound_mode', | ||
| 'schema': MEDIA_PLAYER_SELECT_SOUND_MODE_SCHEMA}, | ||
| SERVICE_PLAY_MEDIA: { | ||
| 'method': 'async_play_media', | ||
| 'schema': MEDIA_PLAYER_PLAY_MEDIA_SCHEMA}, | ||
|
|
@@ -197,6 +208,8 @@ | |
| ATTR_APP_NAME, | ||
| ATTR_INPUT_SOURCE, | ||
| ATTR_INPUT_SOURCE_LIST, | ||
| ATTR_SOUND_MODE, | ||
| ATTR_SOUND_MODE_LIST, | ||
| ATTR_MEDIA_SHUFFLE, | ||
| ] | ||
|
|
||
|
|
@@ -346,6 +359,17 @@ def select_source(hass, source, entity_id=None): | |
| hass.services.call(DOMAIN, SERVICE_SELECT_SOURCE, data) | ||
|
|
||
|
|
||
| @bind_hass | ||
| def select_sound_mode(hass, sound_mode, entity_id=None): | ||
| """Send the media player the command to select sound mode.""" | ||
| data = {ATTR_SOUND_MODE: sound_mode} | ||
|
|
||
| if entity_id: | ||
| data[ATTR_ENTITY_ID] = entity_id | ||
|
|
||
| hass.services.call(DOMAIN, SERVICE_SELECT_SOUND_MODE, data) | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank line contains whitespace |
||
| @bind_hass | ||
| def clear_playlist(hass, entity_id=None): | ||
| """Send the media player the command for clear playlist.""" | ||
|
|
@@ -399,6 +423,8 @@ async def async_service_handler(service): | |
| params['position'] = service.data.get(ATTR_MEDIA_SEEK_POSITION) | ||
| elif service.service == SERVICE_SELECT_SOURCE: | ||
| params['source'] = service.data.get(ATTR_INPUT_SOURCE) | ||
| elif service.service == SERVICE_SELECT_SOUND_MODE: | ||
| params['sound_mode'] = service.data.get(ATTR_SOUND_MODE) | ||
| elif service.service == SERVICE_PLAY_MEDIA: | ||
| params['media_type'] = \ | ||
| service.data.get(ATTR_MEDIA_CONTENT_TYPE) | ||
|
|
@@ -580,6 +606,16 @@ def source_list(self): | |
| """List of available input sources.""" | ||
| return None | ||
|
|
||
| @property | ||
| def sound_mode(self): | ||
| """Name of the current sound mode.""" | ||
| return None | ||
|
|
||
| @property | ||
| def sound_mode_list(self): | ||
| """List of available sound modes.""" | ||
| return None | ||
|
|
||
| @property | ||
| def shuffle(self): | ||
| """Boolean if shuffle is enabled.""" | ||
|
|
@@ -723,6 +759,17 @@ def async_select_source(self, source): | |
| """ | ||
| return self.hass.async_add_job(self.select_source, source) | ||
|
|
||
| def select_sound_mode(self, sound_mode): | ||
| """Select sound mode.""" | ||
| raise NotImplementedError() | ||
|
|
||
| def async_select_sound_mode(self, sound_mode): | ||
| """Select sound mode. | ||
|
|
||
| This method must be run in the event loop and returns a coroutine. | ||
| """ | ||
| return self.hass.async_add_job(self.select_sound_mode, sound_mode) | ||
|
|
||
| def clear_playlist(self): | ||
| """Clear players playlist.""" | ||
| raise NotImplementedError() | ||
|
|
@@ -796,6 +843,11 @@ def support_select_source(self): | |
| """Boolean if select source command supported.""" | ||
| return bool(self.supported_features & SUPPORT_SELECT_SOURCE) | ||
|
|
||
| @property | ||
| def support_select_sound_mode(self): | ||
| """Boolean if select sound mode command supported.""" | ||
| return bool(self.supported_features & SUPPORT_SELECT_SOUND_MODE) | ||
|
|
||
| @property | ||
| def support_clear_playlist(self): | ||
| """Boolean if clear playlist command supported.""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace