Media player
Domain media_player: states, services, device classes and features.
Entity ids in this domain look like media_player.<object_id>.
Use in preferences
{ key: 'device', label: 'Device', type: 'entity', domainFilter: 'media_player', required: true }States
getState() returns the raw token. subscribe filters, entity.is() and matchesState() also accept the friendly label the app shows (any case; spaces, hyphens and underscores interchangeable).
playingpausedstoppedbuffering
subscribe($g.device, { to: 'playing' }, onChange);
if ($g.device.is('playing')) { /* … */ }Services
Curated for smart apps (also offered by the wizard action catalog):
| Service | Parameters | Description |
|---|---|---|
mute | — | Mute |
next | — | Next track |
pause | — | Pause |
play | — | Play |
playMedia | mediaContentId (string, required) | Play a stream or file by its address (http URL, or a URI from a source browse). |
previous | — | Previous track |
setVolume | volume (number, 0–100, required) | Set volume |
stop | — | Stop |
turnOff | — | Turn off |
turnOn | — | Turn on |
unmute | — | Unmute |
volumeDown | — | Volume down |
volumeUp | — | Volume up |
await $g.device.mute();Also routable (MediaPlayerServices), not in the wizard catalog — callable as entity.<service>(); the integration may reject unsupported ones at runtime:
joinGroup, seek, setGroupVolume, unjoinGroup
Device classes
none, tv, speaker, receiver, projector
Filter with deviceClassFilter in an entity input.
Features
Bitmask on the supportedFeatures attribute; read the values with getEntityFeatures().MediaPlayer.
| Feature | Bit |
|---|---|
PAUSE | 1 |
SEEK | 2 |
VOLUME_SET | 4 |
VOLUME_MUTE | 8 |
PREVIOUS_TRACK | 16 |
NEXT_TRACK | 32 |
TURN_ON | 128 |
TURN_OFF | 256 |
PLAY_MEDIA | 512 |
VOLUME_STEP | 1024 |
SELECT_SOURCE | 2048 |
STOP | 4096 |
CLEAR_PLAYLIST | 8192 |
PLAY | 16384 |
SHUFFLE_SET | 32768 |
SELECT_SOUND_MODE | 65536 |
BROWSE_MEDIA | 131072 |
REPEAT_SET | 262144 |
GROUPING | 524288 |
MEDIA_ANNOUNCE | 1048576 |
MEDIA_ENQUEUE | 2097152 |
SEARCH_MEDIA | 4194304 |