Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Ability to fire the media browser from any card as an action #7145

Closed
RomRider opened this issue Sep 27, 2020 · 8 comments
Closed

Ability to fire the media browser from any card as an action #7145

RomRider opened this issue Sep 27, 2020 · 8 comments
Labels
Feature Request Should be a discussion

Comments

@RomRider
Copy link
Contributor

The request

I'd like to be able to display the media browser from a media_player entity from any card. Right now, firing the show-dialog event with the dialogTag: 'dialog-media-player-browse' doesn't work because the media browser is not loaded. If it is loaded first though a standard media_player card, it works. I wouldn't want to duplicate the media browser in a custom card.

The alternatives

None

Additional information

Something like this below currently doesn't work in a custom-card unless it has been displayed before through a core media_player card. dialogImport is omitted as it would require to duplicate all the code from the media browser which is far from ideal.

  private _handleMediaBrowerEvent(actionConfig: MediaBrowserActionConfig): void {
    fireEvent(this, 'show-dialog', {
      dialogTag: 'dialog-media-player-browse',
      dialogParams: {
        action: 'play',
        entityId: actionConfig.entity_id ? actionConfig.entity_id : this._config?.entity,
        mediaPickedCallback: (pickedMedia: any) => {
          this._hass!.callService('media_player', 'play_media', {
            entity_id: actionConfig.entity_id ? actionConfig.entity_id : this._config?.entity,
            media_content_id: pickedMedia.item.media_content_id,
            media_content_type: pickedMedia.item.media_content_type,
          });
        },
      },
    });
  }
@1ntroduc3
Copy link

We;d love to have this feature. So we can launch the mediabrowser from another side.

@RomRider
Copy link
Contributor Author

An approach would be a service type like more-info but for it would be called media-browser.
@bramkragten, what do you think?

@1ntroduc3
Copy link

Is there any update on this feature? This would add great possibilities.

@ncodee
Copy link

ncodee commented Mar 9, 2021

+1, hopefully this is feasible and gets implemented soon.

@bramkragten
Copy link
Member

An approach would be a service type like more-info but for it would be called media-browser.
@bramkragten, what do you think?

That would not be the way to go, if we wanted to implement this, we should expose the showMediaBrowserDialog in custom-card-helpers. But this is always a tricky point, as it will hinder our development since we now have to consider custom cards when making changes.

https://github.com/home-assistant/frontend/blob/add-fallback-to-serviceworker/src/components/media-player/show-media-browser-dialog.ts#L15

@1ntroduc3
Copy link

Please do consider it. It would make so much great use cases

@RomRider
Copy link
Contributor Author

RomRider commented Mar 9, 2021

I'd not consider custom-cards as a blocker for this when making changes, but notifying in some ways that changes are happening would be great (as it is for every other accessible components). Then I'd say it's up to the custom-card's dev to figure out what those changes are.

I'd rather have the option and it breaking in a custom card at some point than not having the option at all.

@1ntroduc3
Copy link

I'd not consider custom-cards as a blocker for this when making changes, but notifying in some ways that changes are happening would be great (as it is for every other accessible components). Then I'd say it's up to the custom-card's dev to figure out what those changes are.

I'd rather have the option and it breaking in a custom card at some point than not having the option at all.

I agree. This also works for other custom functions that are made available.

@home-assistant home-assistant locked and limited conversation to collaborators Jan 12, 2022
@zsarnett zsarnett converted this issue into discussion #11300 Jan 12, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Feature Request Should be a discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants