KoljaWindeler / ytube_music_player

YouTube music player for homeassistant
345 stars 53 forks source link

Media player is stopping after one song of a playlist chosen with the new SELECT entity #339

Closed wtaferner closed 6 months ago

wtaferner commented 6 months ago

Describe the bug It seems that there is some issue with the new playlist entity. After choosing a playlist, it will start to be played but is stopping after one song and you are supposed to manually call the next service on the player which is weird for a playlist.

Version 20240420.02 + manual fix for deprecated methods (pendling PR)

To Reproduce

wtaferner commented 6 months ago

It seems like the song is running again in the player (progress bar), but nothing to hear...

I have two different players configured in my HA instance (if it matters for reproduction)

After looking into the code, it seems to be a quite common issue with several mitigation approaches... https://github.com/KoljaWindeler/ytube_music_player/blob/main/custom_components/ytube_music_player/media_player.py#L797

Keeping fingers crossed that the latest HA release and changes might improve things as this looks really messy 🤞🏼

It was working for me until the change of the input entities

I have Google Nest Audio, Nest Mini and Nest Hub as remote media player in place.

mang1985 commented 6 months ago

I have also reproduced this issue. VLC is working fine, but the Chromecast device is not.After playing one song, the Chromecast remains in an idle state and does not continue playing.

mang1985 commented 6 months ago

It appears that the issue might be related to using the new async_track_state_change_event method(#335), which now passes an event object to the callback function instead of entity_id, old_state, and new_state parameters. This change could potentially lead to other issues. I will attempt to see if I can fix the problem based on this new method.

wtaferner commented 6 months ago

For mitigation with the HA onboard automations I did this:

alias: YTubeMusic Mitigation Playlist (Player A)
description: ""
trigger:
  - platform: template
    value_template: |
      {% 
        set players = states.media_player | selectattr(
          'name', 'search', states('select.ytube_music_player_a_speaker')
        )  
      %} 
      {% set entity = players | map(attribute='entity_id') | list | first %} 
      {% if states(entity) == 'idle' %}true{% endif %}
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition:
  - condition: state
    entity_id: media_player.ytube_music_player_a
    state: playing
action:
  - service: media_player.media_next_track
    metadata: {}
    data: {}
    target:
      entity_id: media_player.ytube_music_player_a
mode: single
mang1985 commented 6 months ago

@wtaferner If you have time, please try to see if this can work properly. https://github.com/mang1985/ytube_music_player/commit/c083c0dcd2dcbbf060f5214ef6c2d55ffbbb0f5f

wtaferner commented 6 months ago

@mang1985 You have nailed it. It is working as expected again.

Thank you 🙏🏼

wtaferner commented 6 months ago

Resolved with https://github.com/KoljaWindeler/ytube_music_player/pull/337