Creating object with two entities

I am working on adding media player controls to my floorplan. In the picture below, I am looking to have the “pause” button change to a play button when the music is stopped. I would also like to press the play/pause button to have the music start/stop.I can get them to work separately, by have the picture update and the dark rectangle be the actual toggle, but I was wondering if it is possible to use the play/pause script with the image template?

Below is my attempt at getting this to work, but nothing appears on the floorplan when I use it. Any help would be appreciated.

        - name: spotify_play_pause
          entities:
            - script.spotify_play_pause
          image_template: '
            var imageName = "";

            switch (media_player.spotify.state) {
              case "paused":
                imageName = "play";
                break;
              case "stopped":
                imageName = "play";
                break;
              case "playing":
                imageName = "pause";
                break;
            }

            return "/local/custom_ui/floorplan/images/spotify/" + imageName + ".svg";
            '
          action:
            service: toggle