1 """Demo implementation of the media player."""
3 from __future__
import annotations
5 from datetime
import datetime
9 MediaPlayerDeviceClass,
11 MediaPlayerEntityFeature,
24 config_entry: ConfigEntry,
25 async_add_entities: AddEntitiesCallback,
27 """Set up the Demo config entry."""
33 "♥♥ The Best Fireplace Video (3 hours)",
37 "Bedroom",
"kxopViU98Xo",
"Epic sax guy 10 hours", 360000
48 SOUND_MODE_LIST = [
"Music",
"Movie"]
49 DEFAULT_SOUND_MODE =
"Music"
51 YOUTUBE_PLAYER_SUPPORT = (
52 MediaPlayerEntityFeature.PAUSE
53 | MediaPlayerEntityFeature.VOLUME_SET
54 | MediaPlayerEntityFeature.VOLUME_MUTE
55 | MediaPlayerEntityFeature.TURN_ON
56 | MediaPlayerEntityFeature.TURN_OFF
57 | MediaPlayerEntityFeature.PLAY_MEDIA
58 | MediaPlayerEntityFeature.PLAY
59 | MediaPlayerEntityFeature.SHUFFLE_SET
60 | MediaPlayerEntityFeature.SELECT_SOUND_MODE
61 | MediaPlayerEntityFeature.SEEK
62 | MediaPlayerEntityFeature.STOP
65 MUSIC_PLAYER_SUPPORT = (
66 MediaPlayerEntityFeature.PAUSE
67 | MediaPlayerEntityFeature.VOLUME_SET
68 | MediaPlayerEntityFeature.VOLUME_MUTE
69 | MediaPlayerEntityFeature.TURN_ON
70 | MediaPlayerEntityFeature.TURN_OFF
71 | MediaPlayerEntityFeature.CLEAR_PLAYLIST
72 | MediaPlayerEntityFeature.GROUPING
73 | MediaPlayerEntityFeature.PLAY
74 | MediaPlayerEntityFeature.SHUFFLE_SET
75 | MediaPlayerEntityFeature.REPEAT_SET
76 | MediaPlayerEntityFeature.VOLUME_STEP
77 | MediaPlayerEntityFeature.PREVIOUS_TRACK
78 | MediaPlayerEntityFeature.NEXT_TRACK
79 | MediaPlayerEntityFeature.SELECT_SOUND_MODE
80 | MediaPlayerEntityFeature.STOP
83 NETFLIX_PLAYER_SUPPORT = (
84 MediaPlayerEntityFeature.PAUSE
85 | MediaPlayerEntityFeature.TURN_ON
86 | MediaPlayerEntityFeature.TURN_OFF
87 | MediaPlayerEntityFeature.SELECT_SOURCE
88 | MediaPlayerEntityFeature.PLAY
89 | MediaPlayerEntityFeature.SHUFFLE_SET
90 | MediaPlayerEntityFeature.PREVIOUS_TRACK
91 | MediaPlayerEntityFeature.NEXT_TRACK
92 | MediaPlayerEntityFeature.SELECT_SOUND_MODE
93 | MediaPlayerEntityFeature.STOP
96 BROWSE_PLAYER_SUPPORT = MediaPlayerEntityFeature.BROWSE_MEDIA
100 """A demo media players."""
102 _attr_should_poll =
False
103 _attr_sound_mode_list = SOUND_MODE_LIST
108 self, name: str, device_class: MediaPlayerDeviceClass |
None =
None
110 """Initialize the demo device."""
120 """Turn the media player on."""
121 self.
_attr_state_attr_state = MediaPlayerState.PLAYING
125 """Turn the media player off."""
130 """Mute the volume."""
135 """Increase volume."""
141 """Decrease volume."""
147 """Set the volume level, range 0..1."""
152 """Send play command."""
153 self.
_attr_state_attr_state = MediaPlayerState.PLAYING
157 """Send pause command."""
158 self.
_attr_state_attr_state = MediaPlayerState.PAUSED
162 """Send stop command."""
167 """Enable/disable shuffle mode."""
172 """Select sound mode."""
178 """A Demo media player that only supports YouTube."""
182 _attr_app_name =
"YouTube"
183 _attr_media_content_type = MediaType.MOVIE
184 _attr_supported_features = YOUTUBE_PLAYER_SUPPORT
187 self, name: str, youtube_id: str, media_title: str, duration: int
189 """Initialize the demo device."""
194 self.
_progress_progress: int |
None =
int(duration * 0.15)
199 """Return the image url of current playing media."""
200 return f
"https://img.youtube.com/vi/{self.media_content_id}/hqdefault.jpg"
204 """Position of current playing media in seconds."""
219 """When was the position of the current playing media valid.
221 Returns value from homeassistant.util.dt.utcnow().
228 self, media_type: MediaType | str, media_id: str, **kwargs: Any
230 """Play a piece of media."""
235 """Send pause command."""
242 """A Demo media player."""
246 _attr_media_album_name =
"Bounzz"
247 _attr_media_content_id =
"bounzz-1"
248 _attr_media_content_type = MediaType.MUSIC
249 _attr_media_duration = 213
250 _attr_media_image_url = (
251 "https://graph.facebook.com/v2.5/107771475912710/picture?type=large"
253 _attr_supported_features = MUSIC_PLAYER_SUPPORT
256 (
"Technohead",
"I Wanna Be A Hippy (Flamman & Abraxas Radio Mix)"),
257 (
"Paul Elstak",
"Luv U More"),
258 (
"Dune",
"Hardcore Vibes"),
259 (
"Nakatomi",
"Children Of The Night"),
260 (
"Party Animals",
"Have You Ever Been Mellow? (Flamman & Abraxas Radio Mix)"),
261 (
"Rob G.*",
"Ecstasy, You Got What I Need"),
262 (
"Lipstick",
"I'm A Raver"),
263 (
"4 Tune Fairytales",
"My Little Fantasy (Radio Edit)"),
264 (
"Prophet",
"The Big Boys Don't Cry"),
265 (
"Lovechild",
"All Out Of Love (DJ Weirdo & Sim Remix)"),
266 (
"Stingray & Sonic Driver",
"Cold As Ice (El Bruto Remix)"),
267 (
"Highlander",
"Hold Me Now (Bass-D & King Matthew Remix)"),
268 (
"Juggernaut",
'Ruffneck Rules Da Artcore Scene (12" Edit)'),
269 (
"Diss Reaction",
"Jiiieehaaaa "),
270 (
"Flamman And Abraxas",
"Good To Go (Radio Mix)"),
271 (
"Critical Mass",
"Dancing Together"),
273 "Charly Lownoise & Mental Theo",
274 "Ultimate Sex Track (Bass-D & King Matthew Remix)",
279 """Initialize the demo device."""
287 """Return the title of current playing media."""
292 """Return the artist of current playing media (Music track only)."""
297 """Return the track number of current media (Music track only)."""
301 """Send previous track command."""
307 """Send next track command."""
313 """Clear players playlist."""
320 """Enable/disable repeat mode."""
325 """Join `group_members` as a player group with the current player."""
330 """Remove this player from any group."""
336 """A Demo media player that only supports Netflix."""
340 _attr_app_name =
"Netflix"
341 _attr_media_content_id =
"house-of-cards-1"
342 _attr_media_content_type = MediaType.TVSHOW
343 _attr_media_duration = 3600
344 _attr_media_image_url = (
345 "https://graph.facebook.com/v2.5/HouseofCards/picture?width=400"
347 _attr_media_season =
"1"
348 _attr_media_series_title =
"House of Cards"
349 _attr_source_list = [
"dvd",
"youtube"]
350 _attr_supported_features = NETFLIX_PLAYER_SUPPORT
353 """Initialize the demo device."""
354 super().
__init__(
"Lounge room", MediaPlayerDeviceClass.TV)
361 """Return the title of current playing media."""
362 return f
"Chapter {self._cur_episode}"
366 """Return the episode of current playing media (TV Show only)."""
370 """Send previous track command."""
376 """Send next track command."""
382 """Set the input source."""
388 """A Demo media player that supports browse."""
390 _attr_supported_features = BROWSE_PLAYER_SUPPORT
394 """A Demo media player that supports grouping."""
396 _attr_supported_features = (
397 YOUTUBE_PLAYER_SUPPORT
398 | MediaPlayerEntityFeature.GROUPING
399 | MediaPlayerEntityFeature.TURN_OFF
None schedule_update_ha_state(self, bool force_refresh=False)