Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow notification media player controls #1009

Open
timkoers opened this issue Oct 5, 2020 · 12 comments
Open

Allow notification media player controls #1009

timkoers opened this issue Oct 5, 2020 · 12 comments
Labels
enhancement New feature or request notifications

Comments

@timkoers
Copy link

timkoers commented Oct 5, 2020

Is your feature request related to a problem? Please describe.
No it is not related to a problem, I was just wondering about how I could integrate contextual locations/rooms into Home Assistant.
In order to realise this, a few other things are needed, one of them is this feature request.
It would be nice if a notify service call could make an media player notification show up on a device, and with that, specifying which media_player component should handle the play/pause back/next controls and which media_player component should handle the volume controls (which I think should replace the thumbs on the image below)

Describe the solution you'd like
HomeAssistant should integrate the mediaplayer controls as seen in the image below, but then for specific media_player entities, one used for playback control and another one used for volume control.

Describe alternatives you've considered, if any
None.

Additional context

An example of the mediaplayer controls I'm talking about

@timkoers timkoers added the enhancement New feature or request label Oct 5, 2020
@dshokouhi
Copy link
Member

Not quite a notification but #1005 would allow you to create home screen widgets, one for each media player.

@JBassett
Copy link
Collaborator

JBassett commented Oct 5, 2020

Guide on how it could be done: https://developer.android.com/guide/topics/media/media-controls. The PR that @dshokouhi mentioned has the service calls needed to hook up to the interface. The entities could be selected in the settings menus but I'm not sure how we would resurface the media player after it was dismissed.

@timkoers
Copy link
Author

timkoers commented Oct 5, 2020

Guide on how it could be done: https://developer.android.com/guide/topics/media/media-controls. The PR that @dshokouhi mentioned has the service calls needed to hook up to the interface. The entities could be selected in the settings menus

I'd like to have it settings menu independend, so you provide the media_player entities as the data that will get send together with notification. Just like a picture notification, only now, a mediaplayer notification.

but I'm not sure how we would resurface the media player after it was dismissed.

You mean that when you swipe the notification away, how it comes back? Well, in my mind that should be done by a HomeAssistant automation, which pushes the notification to the device.

@JBassett
Copy link
Collaborator

JBassett commented Oct 5, 2020

Using the notification system is an interesting idea. That seems like a decent way to remove the need for more settings and a good way to resurface the media player.

@timkoers
Copy link
Author

timkoers commented Oct 5, 2020

The only thing, is that when a user is streaming from the phone, to the media player, a media player notification for the same context gets shown twice.
So I think it's good to have somekind of feedback to HomeAssistant if a media player notification is already being shown (from any app).

@ncodee
Copy link

ncodee commented Mar 9, 2021

Has this been implemented, or being considered?

@dshokouhi
Copy link
Member

Has this been implemented, or being considered?

the enhancement request is still open so it has not been implemented yet, anyone who wants to implement it can pick it up

@stale
Copy link

stale bot commented Jan 9, 2022

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@TheWhiteGandalf
Copy link

TheWhiteGandalf commented Jun 25, 2023

Any chance this will ever be implemented? I want this so badly

@dnestico
Copy link

Same it would be a game changer if possible

@eyal1izhaki
Copy link

Would be awesome

@matthewdias
Copy link

In lieu of native android media controls, I created an automation for this using regular notifications. You may need to tweak based on the behavior of your media player

alias: Desk Speakers Media Remote
description: ""
trigger:
  - id: media_on
    platform: state
    entity_id:
      - media_player.desk_speakers
    from:
      - "off"
      - standby
      - idle
    to:
      - "on"
      - paused
      - playing
      - buffering
  - id: media_pause
    platform: state
    entity_id:
      - media_player.desk_speakers
    from:
      - playing
      - buffering
    to: paused
  - id: media_off
    platform: state
    entity_id:
      - media_player.desk_speakers
    to:
      - "off"
      - standby
      - idle
  - id: media_play
    platform: state
    entity_id:
      - media_player.desk_speakers
    from: paused
    to:
      - playing
      - buffering
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: PLAY_PAUSE_DESK_SPEAKERS
    id: action_play_pause
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: NEXT_DESK_SPEAKERS
    id: action_next
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: TURN_OFF_DESK_SPEAKERS
    id: action_turn_off
  - platform: state
    entity_id:
      - media_player.desk_speakers
    attribute: media_title
    id: media_change
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - media_on
              - media_play
        sequence:
          - service: notify.mobile_app_pixel_8
            metadata: {}
            data:
              title: >
                {{ state_attr('media_player.desk_speakers','media_title') }} -
                {{ state_attr('media_player.desk_speakers','media_artist') }}
              message: >
                Desk Speakers -
                {{state_attr('media_player.desk_speakers','source')}}
              data:
                persistent: true
                sticky: true
                tag: desk_speakers_media
                notification_icon: mdi:speaker
                channel: Media
                importance: max
                image: >
                  {{ state_attr('media_player.desk_speakers','entity_picture')
                  }}
                actions:
                  - action: PLAY_PAUSE_DESK_SPEAKERS
                    title: Play/Pause
                  - action: NEXT_DESK_SPEAKERS
                    title: Next
                  - action: TURN_OFF_DESK_SPEAKERS
                    title: Stop
      - conditions:
          - condition: trigger
            id:
              - media_off
        sequence:
          - service: notify.mobile_app_pixel_8
            metadata: {}
            data:
              message: clear_notification
              data:
                tag: desk_speakers_media
      - conditions:
          - condition: trigger
            id:
              - action_play_pause
        sequence:
          - service: media_player.media_play_pause
            target:
              entity_id:
                - media_player.desk_speakers
            data: {}
      - conditions:
          - condition: trigger
            id:
              - action_next
        sequence:
          - service: media_player.media_next_track
            target:
              entity_id:
                - media_player.desk_speakers
            data: {}
      - conditions:
          - condition: trigger
            id:
              - action_turn_off
        sequence:
          - service: media_player.media_stop
            target:
              entity_id:
                - media_player.desk_speakers
            data: {}
      - conditions:
          - condition: trigger
            id:
              - media_pause
          - condition: not
            conditions:
              - condition: template
                value_template: >-
                  {{ state_attr('media_player.desk_speakers','media_title') is
                  none }}
        sequence:
          - service: notify.mobile_app_pixel_8
            metadata: {}
            data:
              title: >
                {{ state_attr('media_player.desk_speakers','media_title') }} -
                {{ state_attr('media_player.desk_speakers','media_artist') }}
              message: >
                Desk Speakers -
                {{state_attr('media_player.desk_speakers','source')}}
              data:
                persistent: true
                sticky: true
                tag: desk_speakers_media
                notification_icon: mdi:speaker-pause
                channel: Media
                importance: max
                image: >
                  {{ state_attr('media_player.desk_speakers','entity_picture')
                  }}
                actions:
                  - action: PLAY_PAUSE_DESK_SPEAKERS
                    title: Play
                  - action: NEXT_DESK_SPEAKERS
                    title: Next
                  - action: TURN_OFF_DESK_SPEAKERS
                    title: Stop
      - conditions:
          - condition: trigger
            id:
              - media_change
          - condition: not
            conditions:
              - condition: template
                value_template: >-
                  {{ state_attr('media_player.desk_speakers','media_title') is
                  none }}
        sequence:
          - service: notify.mobile_app_pixel_8
            metadata: {}
            data:
              title: >
                {{ state_attr('media_player.desk_speakers','media_title') }} -
                {{ state_attr('media_player.desk_speakers','media_artist') }}
              message: >
                Desk Speakers -
                {{state_attr('media_player.desk_speakers','source')}}
              data:
                persistent: true
                sticky: true
                tag: desk_speakers_media
                notification_icon: mdi:speaker
                channel: Media
                importance: max
                image: >
                  {{ state_attr('media_player.desk_speakers','entity_picture')
                  }}
                actions:
                  - action: PLAY_PAUSE_DESK_SPEAKERS
                    title: Play/Pause
                  - action: NEXT_DESK_SPEAKERS
                    title: Next
                  - action: TURN_OFF_DESK_SPEAKERS
                    title: Stop
mode: queued
max: 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request notifications
Projects
None yet
Development

No branches or pull requests

8 participants