Media Player Entity

Incomplete

This entry is incomplete. Contribution welcome.

A media player entity controls a media player. Derive a platform entity from homeassistant.components.media_player.MediaPlayerEntity.

Properties

tip

Properties should always only return information from memory and not do I/O (like network requests). Implement update() or async_update() to fetch data.

NameTypeDefaultDescription
supported_featuresintintFlag supported features.
sound_modestringNoneThe current sound mode of the media player
sound_mode_listlistNoneDynamic list of available sound modes (set by platform, empty means sound mode not supported)
sourcestringNoneThe currently selected input source for the media player.
source_listlistNoneThe list of possible input sources for the media player. (This list should contain human readable names, suitible for frontend display)
media_image_urlstringNoneURL that represents the current image.
media_image_remotely_accessiblebooleanFalseReturn True if property media_image_url is accessible outside of the home network.
device_classstringNoneType of media player.

Supported Features

ConstantDescription
SUPPORT_CLEAR_PLAYLISTEntity allows clearing the active playlist.
SUPPORT_NEXT_TRACKEntity allows skipping to the next media track.
SUPPORT_PAUSEEntity allows pausing the playback of media.
SUPPORT_PLAYEntity allows playing/resuming playback of media.
SUPPORT_PLAY_MEDIAEntity allows playing media sources.
SUPPORT_PREVIOUS_TRACKEntity allows returning back to a previous media track.
SUPPORT_SEEKEntity allows seeking position during playback of media.
SUPPORT_SELECT_SOURCEEntity allows selecting a source/input.
SUPPORT_SELECT_SOUND_MODEEntity allows selecting a sound mode.
SUPPORT_SHUFFLE_SETEntity allows shuffling the active playlist.
SUPPORT_STOPEntity allows stopping the playback of media.
SUPPORT_TURN_OFFEntity is able to be turned off.
SUPPORT_TURN_ONEntity is able to be turned on.
SUPPORT_VOLUME_MUTEEntity volume can be muted.
SUPPORT_VOLUME_SETEntity volume can be set to specific levels.
SUPPORT_VOLUME_STEPEntity volume can be adjusted up and down.

Methods

Select sound mode

Optional. Switch the sound mode of the media player.

class MyMediaPlayer(MediaPlayerEntity):
# Implement one of these methods.
def select_sound_mode(self, sound_mode):
"""Switch the sound mode of the entity."""
def async_select_sound_mode(self, sound_mode):
"""Switch the sound mode of the entity."""

Select source

Optional. Switch the selected input source for the media player.

class MyMediaPlayer(MediaPlayerEntity):
# Implement one of these methods.
def select_source(self, source):
"""Select input source."""
def async_select_source(self, source):
"""Select input source."""

Mediatype

Required. Returns one of the defined constants from the below list that matches the mediatype

CONST
MEDIA_TYPE_MUSIC
MEDIA_TYPE_TVSHOW
MEDIA_TYPE_MOVIE
MEDIA_TYPE_VIDEO
MEDIA_TYPE_EPISODE
MEDIA_TYPE_CHANNEL
MEDIA_TYPE_PLAYLIST
MEDIA_TYPE_IMAGE
MEDIA_TYPE_URL
MEDIA_TYPE_GAME
MEDIA_TYPE_APP
class MyMediaPlayer(MediaPlayerEntity):
# Implement the following method.
@property
def media_content_type(self):
"""Content type of current playing media."""
info

Using the integration name as the media_content_type is also acceptable within the play_media service if the integration provides handling which does not map to the defined constants.

Available device classes

Optional. What type of media device is this. It will possibly map to google device types.

ValueDescription
tvDevice is a television type device.
speakerDevice is speakers or stereo type device.
Last updated on