mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +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
|
||||
def media_duration(self):
|
||||
"""Return the duration of current playing media in seconds."""
|
||||
# Time does not exist for streams
|
||||
return self._currentsong.get("time")
|
||||
if currentsong_time := 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
|
||||
def media_position(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user