Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Feedback on a US Spotify UI (that works!)

This site may earn commission on affiliate links.
I'm back from our honeymoon and am looking into the authentication issue first and foremost. I'm still trying to figure out how Eve does it, and the variety of things I'm trying aren't working.

The worst offender is that the expire time on a cookie isn't respected. I thought of various ways to map a user but they're not secure and could change based on your WiFi or LTE connection.

No matter how nice and handy this app is, signing in every time you get in the car is not at all worth it, so I'm really focusing on this for now.

Please, please, please let me know if you have any ideas for identifying an individual car somehow.
 
Okay, guess what. I think it works!

Here's the flow:
  1. Go to the URL for the first time, and it welcomes you and asks you to hit continue.
  2. Resulting page asks you to bookmark it, as it is a unique URL for you.
  3. You bookmark that page and hit Continue
  4. Authenticate to Spotify.
  5. Joy.
I believe my "rate limit" issue was actually not renewing the authentication token, so I'm going to try that out today.

In the process of doing these changes, I removed all my browser session related code which has the unintended result of making my heartbeat call also hit the database every time. I'll fix that later, I just can't wait to see if this works!
 
@arlorose fellow web developer here and happy to hear someone is doing this! I hear you on the pains of developing for the (surprisingly) bad and dated browser. The UI snapshot you shared looks pretty great especially considering your limitations.

If you’re looking for someone to test, let me know.
 
I'm getting there. :)

"There" being wanting feedback.

I only have an hour here or there to hack on this, but I spend some good time on the behind the scenes pieces this weekend, and now that I seem to have authentication totally dealt with (yesssss...) I'm making the new UI I had to add fit a little better.

Maybe before I go to sleep. Otherwise, I start a new role at work on Monday and I don't really have much to do until noon, so I may hack in the AM.
 
  • Like
Reactions: Cirrus MS100D
Urg. So I just went to start hacking on this (I started to add Playlist display and playback last night)... and as if some sort of cosmic joke was being played on me, the token that "lives virtually forever unless you change your password" had expired overnight.

To make it worse, the redirects that happened in my own code path to refresh them (which translates into needing to hand-enter details in the car, which is a not worth it, but let's ignore that for now), caused an unexplainable crash the Spotify library my code uses.

This is all TMI, and at this point, I feel like a tease, but I enjoy keeping people posted on how things are going.
 
Actually looks like it's a Spotify API outage.

One of the scary side effects is that my app isn't on their developer portal anymore... but Twitter status says they're having issues.

Perhaps now would be a good time to build out the logic to handle a Spotify API outage. :-D

Edit: Yeah, the API itself is going in and out, had nothing to do with the tokens... and they aren't getting invalidated, which is a good sign for future outages. Bad timing, this is one of the few free moments I have to hack on this.
 
Last edited:
  • Like
Reactions: Cirrus MS100D
Okay... I've hit an HTML wall (worst... browser... ever.), so I'm forking this and will let you guys play with what's there.

Far better playlist support, adding items, changing repeat, etc coming soon, but as-is this is super handy.

I need to refine the dialogs (and, in fact, I did them real quick just now so for all I know they don't even render in-car correctly, but the functionality will work).

So... keep this in this thread for now:

Spotify for Tesla

Have fun, and let me know if you have any issues. :)

(I'm going to guess that I'll hit a rate limit or something either with Spotify or my ISP, so if it's not working at all in an hour or so, that's probably why and I'll move to AWS.)


Arlo
 
  • Like
Reactions: Cirrus MS100D
Pressing the next/previous buttons causes the following error in the HTTP call:

Code:
<br />
<b>Fatal error</b>:  Uncaught SpotifyWebAPI\SpotifyWebAPIException: Not available for the current user in /home/arlorose/sqsh.it/s/vendor/jwilsson/spotify-web-api-php/src/Request.php:38
Stack trace:
#0 /home/arlorose/sqsh.it/s/vendor/jwilsson/spotify-web-api-php/src/Request.php(222): SpotifyWebAPI\Request-&gt;parseBody(Object(stdClass), 403)
#1 /home/arlorose/sqsh.it/s/vendor/jwilsson/spotify-web-api-php/src/Request.php(107): SpotifyWebAPI\Request-&gt;send('POST', 'https://api.spo...', '', Array)
#2 /home/arlorose/sqsh.it/s/vendor/jwilsson/spotify-web-api-php/src/SpotifyWebAPI.php(1296): SpotifyWebAPI\Request-&gt;api('POST', '/v1/me/player/n...', Array, Array)
#3 /home/arlorose/sqsh.it/s/calls.php(78): SpotifyWebAPI\SpotifyWebAPI-&gt;next()
#4 {main}
  thrown in <b>/home/arlorose/sqsh.it/s/vendor/jwilsson/spotify-web-api-php/src/Request.php</b> on line <b>38</b><br />
 
@mazeminder

Does it still switch tracks for you even though the error is thrown?

How are you seeing that on the Tesla?

EDIT TO ADD:

If you're using this on the desktop, what browser are you using? Also, are you a Spotify Pro user?

I see this happen here and there (usually from a race condition with desktop Spotify and Mobile Spotify changing control), but not in the many hours of use in-car so far. Worst case I'll improve my error catching and retry code, but I really would rather make sure there isn't some other issue.
 
Tesla browser does support local storage, so you might want to consider using that to store the token, instead of cookies. I don't have any idea how often it gets wiped out, though.

There can be up to a 4-second delay if the user changes tracks via the steering wheel, but overall the basics are in decent shape.

It also supports websockets, so might be worth looking in that. I think it might even support server events, but can't remember of the top of my head.