mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add duration support for streaming in mpd (#66110)
* Add duration support for streaming in mpd * Change to use 1 line instead of if * Improve code to be more readable
This commit is contained in:
parent
d655d54a8f
commit
88780b4c87
@ -227,8 +227,14 @@ class MpdDevice(MediaPlayerEntity):
|
|||||||
@property
|
@property
|
||||||
def media_duration(self):
|
def media_duration(self):
|
||||||
"""Return the duration of current playing media in seconds."""
|
"""Return the duration of current playing media in seconds."""
|
||||||
# Time does not exist for streams
|
if currentsong_time := self._currentsong.get("time"):
|
||||||
return self._currentsong.get("time")
|
return currentsong_time
|
||||||
|
|
||||||
|
time_from_status = self._status.get("time")
|
||||||
|
if isinstance(time_from_status, str) and ":" in time_from_status:
|
||||||
|
return time_from_status.split(":")[1]
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_position(self):
|
def media_position(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user