Lovelace: Mini Media Player

Ok thanks, now it’s clearer… the third card is nested inside an entities card, that’s why i get that background!

1 Like

That’s a good fit for the shortcuts, have the shortcuts call a script with the entity_id and possibly skip_interval as parameters and handle the service call from the script, that way you can reuse the same script in multiple cards or places.

Let me know if you need help with a concrete example.

Yes, a general skip script would be ideal. The problem is I don’t know how to get the progress and duration from the media_player entity. I believe media player only accepts seek_position which is an absolute position in the track, not an interval.

The magic of your card exposes the progress and duration of the track so that a 30 second skip can be calculated and seek_position can be used to skip.

Maybe we could get the HA people to code a seek_interval service call.

Am I missing an easy way to do this in a script?

1 Like

Yes, I need help, thanks!

Okay, this is what I got, what do you think?

The script

skip:
  alias: skip
  sequence:
    - service: media_player.media_seek
      data_template:
        entity_id: "{{ entity }}"
        seek_position: "{{ state_attr(entity, 'media_position') | float + interval }}"

The card

- type: custom:mini-media-player
  entity: media_player.example
  shortcuts:
    buttons:
      - type: script
        id: skip
        icon: mdi:rewind-10
        data:
          entity: media_player.example # Same as card entity
          interval: -10 # Skip in seconds (change by preference)
      - type: script
        id: skip
        icon: mdi:fast-forward-10
        data:
          entity: media_player.example # Same as card entity
          interval: 10 # Skip in seconds (change by preference)

04

This will only work for media players reporting the media_position.
And it will throw an error if media_position + interval < 0 but it’s a good start.

1 Like

Amazing! Thanks!

I can’t believe that I didn’t know that media_position was in the state attributes.

I think I’ll have to use the media_position_updated_at attribute as well because the media_position doesn’t seem to be the current position but the position last time the attributes were updated. Not sure why it doesn’t stay up to date.

1 Like

That’s a smart idea, that’s actually how we calculate and track the progress in the mini-media-player card, some platforms seem to keep it pretty up to date and some less so, for performance reasons I guess. :slightly_smiling_face:

Playing with time was fun.

This is what I got for maths:

seek_position: " {{ ( as_timestamp(now()) - as_timestamp(state_attr(entity, 'media_position_updated_at')) + state_attr(entity, 'media_position') ) | float + interval }} "
3 Likes

Haha, that’s a long line :smile:

Ok, I need some help. I have really tried to get rounded corners on my artwork in mini media player. But I cant!

Here is the code:

- card:
                  artwork: full-cover
                  entity: media_player.spotify
                  hide:
                    controls: false
                    icon: true
                    info: false
                    mute: true
                    name: true
                    power: true
                    power_state: true
                    shuffle: false
                    source: true
                    volume: true
                  info: scroll
                  style: |
                    ha-card {
                      background: none;
                      box-shadow: none;
                      border-radius: 20px;
                      overflow: hidden;
                      width: 60%;
                      margin: 0%;
                      padding-top: 0px;
                      left: 8%;
                      top: 30px;
                    }
                  type: 'custom:mini-media-player'

And this is what I get:
PNG

It seems like none of background, box-shadow, border-radius, overflow is affected when changed. Only width, left etc makes a difference.
As you can see my artwork dont have border radius 20px, its only 10px as set in my theme!

Any help is appreciated!! :slight_smile:

Latest version of mini media player.

  - resources: null
  - type: module
    url: /local/mini-media-player-bundle.js?v=1.4.1

Seems like a bug, when the card is in collapsed config (e.g. volume and/or controls are hidden).
The only thing you should need to set is ha-card-border-radius in your theme.
I’ll fix it tomorrow.

Should now be fixed in the latest release.

I have a very simple configuration that adds a button to play a local radio station that uses m3u8:

      - type: custom:mini-media-player
        entity: media_player.suite_speaker
        artwork: cover
        info: short
        shortcuts:
          buttons:
          - name: Eldorado
            icon: mdi:radio
            type: music
            id: http://estadaohls-lh.akamaihd.net/i/estadaohls_1@301351/master.m3u8

How can I add a second button with a TuneIn radio station ?

Thanks

Still same issue… :frowning:

Actually it seems to be a google chrome problem. It works on my ipad with safari, and on my android with edge and firefox but NOT on my computer or android tablet running google chrome? :o

Just installed the latest release and added the play_stop option, but when running the card and pressing the stop button i get the following:

Fallita chiamata a servizio media_player/media_stop 

Is it my fault in something or what?

I’m not sure about tuneIn, but to add another button, just do like this.
Media content is platform dependant so the id, type and even supported sources may vary between components.

      - type: custom:mini-media-player
        entity: media_player.suite_speaker
        artwork: cover
        info: short
        shortcuts:
          buttons:
            - name: Eldorado
              icon: mdi:radio
              type: music
              id: http://estadaohls-lh.akamaihd.net/i/estadaohls_1@301351/master.m3u8
            - name: Second station
              icon: mdi:radio
              type: music
              id: http://example.com/radio.m3u8

Clear cache maybe? Works as expected for me on Chrome after the latest update (which had the same issue as you had before).

Is it possible that your media player doesn’t support the stop service, what component is it?

Yes, I can add more buttons but can`t get them to play from TUNEIN.

Does anybody have a sample config of Mini Media Player playing from TUNEIN to a Google Home?

Check this, it’s from 2017 but might still be relevant:

media_content_id would be the id and media_content_type would be the type in the shortcut.