nagyrobi / home-assistant-custom-components-linkplay

LinkPlay based media devices integration for Home Assistant.
170 stars 32 forks source link

Duration when playing tts and mp3 via play_media #26

Closed nicjo814 closed 3 years ago

nicjo814 commented 3 years ago

Hi!

I just re-installed HA after a break from the project for a couple of years and realized that the linkplay component was still actively developed, which makes me very happy :-)

I'm trying to get my old NodeRed flows up and running and stumbled into an issue. I'm playing a dynamically generated tts text and need to know the duration of the playback in order to start another stream (online mp3 file) when the tts is "done". However the "media_duration" attribute is not returned by the component when playing tts. I looked at the linkplay API and the "totlen" parameter is there and looks correct when playing the stream. I have the same issue when playing an online mp3 via the "play_media" service by the way.

Looking at the code I see that in media_position(self) and media_duration(self) the actual values are not returned when playing tts. I suspect there is some reason for this that I don't know of :-). Otherwise I would be happy to submit a PR if that's ok.

Really nice work with this custom component!

BR, Niclas

nicjo814 commented 3 years ago

Created a PR for this.

nagyrobi commented 3 years ago

Thanks, it was a good journey to re-learn/practice programming I've done many years ago ;)

nagyrobi commented 3 years ago

Had to revert your PR as it creates an error when playing stream. I'll have to handle this in another way.