diff --git a/blog/2022-09-06-media-player-repeat-mode-deprecation.md b/blog/2022-09-06-media-player-repeat-mode-deprecation.md new file mode 100644 index 00000000..f95bdf85 --- /dev/null +++ b/blog/2022-09-06-media-player-repeat-mode-deprecation.md @@ -0,0 +1,59 @@ +--- +author: epenet +authorURL: https://github.com/epenet +title: "Deprecating media player constants" +--- + +As of Home Assistant Core 2022.10, the following media player constants are deprecated: + + - `MEDIA_CLASS_ALBUM` + - `MEDIA_CLASS_APP` + - `MEDIA_CLASS_ARTIST` + - `MEDIA_CLASS_CHANNEL` + - `MEDIA_CLASS_COMPOSER` + - `MEDIA_CLASS_CONTRIBUTING_ARTIST` + - `MEDIA_CLASS_DIRECTORY` + - `MEDIA_CLASS_EPISODE` + - `MEDIA_CLASS_GAME` + - `MEDIA_CLASS_GENRE` + - `MEDIA_CLASS_IMAGE` + - `MEDIA_CLASS_MOVIE` + - `MEDIA_CLASS_MUSIC` + - `MEDIA_CLASS_PLAYLIST` + - `MEDIA_CLASS_PODCAST` + - `MEDIA_CLASS_SEASON` + - `MEDIA_CLASS_TRACK` + - `MEDIA_CLASS_TV_SHOW` + - `MEDIA_CLASS_URL` + - `MEDIA_CLASS_VIDEO` + + - `MEDIA_TYPE_ALBUM` + - `MEDIA_TYPE_APP` + - `MEDIA_TYPE_APPS` + - `MEDIA_TYPE_ARTIST` + - `MEDIA_TYPE_CHANNEL` + - `MEDIA_TYPE_CHANNELS` + - `MEDIA_TYPE_COMPOSER` + - `MEDIA_TYPE_CONTRIBUTING_ARTIST` + - `MEDIA_TYPE_EPISODE` + - `MEDIA_TYPE_GAME` + - `MEDIA_TYPE_GENRE` + - `MEDIA_TYPE_IMAGE` + - `MEDIA_TYPE_MOVIE` + - `MEDIA_TYPE_MUSIC` + - `MEDIA_TYPE_PLAYLIST` + - `MEDIA_TYPE_PODCAST` + - `MEDIA_TYPE_SEASON` + - `MEDIA_TYPE_TRACK` + - `MEDIA_TYPE_TVSHOW` + - `MEDIA_TYPE_URL` + - `MEDIA_TYPE_VIDEO` + + - `REPEAT_MODE_ALL` + - `REPEAT_MODE_OFF` + - `REPEAT_MODE_ONE` + - `REPEAT_MODES` + +Use the new `MediaClass`, `MediaType`, and `RepeatMode` enum instead. + +The use of `STATE_*` constants to reflect media player state is also deprecated. Please use the new `MediaPlayerState` enum instead. diff --git a/docs/core/entity/media-player.md b/docs/core/entity/media-player.md index 30668175..5f6054a8 100644 --- a/docs/core/entity/media-player.md +++ b/docs/core/entity/media-player.md @@ -55,17 +55,17 @@ and are combined using the bitwise or (`|`) operator. ## States -The state of a media player can take the following possible values. +The state of a media player is defined by using values in the `MediaPlayerState` enum, and can take the following possible values. -| Value | Description | -|-------------------|---------------------------------------------------------------------------------------------------------------------| -| `STATE_OFF` | Entity is turned off and is not accepting commands until turned on. | -| `STATE_ON` | Entity is turned on, but no details on its state is currently known. | -| `STATE_IDLE` | Entity is turned on and accepting commands, but currently not playing any media. Possibly at some idle home screen. | -| `STATE_PLAYING` | Entity is currently playing media. | -| `STATE_PAUSED` | Entity has an active media and is currently paused | -| `STATE_STANDBY` | Entity is in a low power state, accepting commands. | -| `STATE_BUFFERING` | Entity is preparing to start playback of some media | +| Value | Description | +|-------------|---------------------------------------------------------------------------------------------------------------------| +| `OFF` | Entity is turned off and is not accepting commands until turned on. | +| `ON` | Entity is turned on, but no details on its state is currently known. | +| `IDLE` | Entity is turned on and accepting commands, but currently not playing any media. Possibly at some idle home screen. | +| `PLAYING` | Entity is currently playing media. | +| `PAUSED` | Entity has an active media and is currently paused | +| `STANDBY` | Entity is in a low power state, accepting commands. | +| `BUFFERING` | Entity is preparing to start playback of some media | ## Methods @@ -157,7 +157,7 @@ class MyMediaPlayer(MediaPlayerEntity): ) -> None: """Play a piece of media.""" if media_source.is_media_source_id(media_id): - media_type = MEDIA_TYPE_MUSIC + media_type = MediaType.MUSIC play_item = await media_source.async_resolve_media(self.hass, media_id, self.entity_id) # play_item returns a relative URL if it has to be resolved on the Home Assistant host # This call will turn it into a full URL @@ -199,21 +199,21 @@ class MyMediaPlayer(MediaPlayerEntity): ### Mediatype -Required. Returns one of the defined constants from the below list that matches the mediatype +Required. Returns one of the values from the MediaType enum 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| +|MediaType.MUSIC| +|MediaType.TVSHOW| +|MediaType.MOVIE| +|MediaType.VIDEO| +|MediaType.EPISODE| +|MediaType.CHANNEL| +|MediaType.PLAYLIST| +|MediaType.IMAGE| +|MediaType.URL| +|MediaType.GAME| +|MediaType.APP| ```python class MyMediaPlayer(MediaPlayerEntity):