• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Building a Spotify player for my Mac SE/30

ants

Well-known member
Hi all, I built a Spotify player for my Macintosh SE/30:

macplayer_front.jpg

The app is called MacPlayer and works thanks to the magic of Spotify Connect. The speaker itself streams and plays the music, and the Mac simply tells the speaker which song to play (as well as volume, current playlist, shuffle mode and other settings). Communication is over Wifi:

macplayer_back.jpg

The first version is pretty basic, it just plays your Spotify playlists. You can browse tracks, and the app displays 1-bit album art, which I think is a bit of fun:

album-1.pngalbum-2.pngalbum-3.pngalbum-4.pngalbum-5.pngalbum-6.png

You can also choose which device to play from via the Devices menu:

devices.png

The app performs well on a stock SE/30, although it does rely on a bit of help from the on-board OpenWRT Wifi router to handle the HTTPS communication with the Spotify API. The router has stunnel installed on it, which acts as a HTTP to HTTPS tunnel. I updated the MacWifi Extension to allow the Mac to create SSL tunnels on the router as needed. Here’s a video of how the app performs (no music unfortunately due to Copyright):


Another problem I had to solve was authenticating the app with a Spotify account. Like most modern web API’s, Spotify uses OAuth to allow third party apps to access their services. However the OAuth flow requires a modern web browser for users to enter their login details. To overcome this, I wrote an OAuth bridge for vintage Macs which delegates the login part of the process to another device such as a smartphone. The first steps are handled on the Mac:

login-1.pnglogin-2.png

And then completed on a modern device:

macauth-1.png macauth-2.png macauth-3.png

The final hurdle was with text encoding. The modern web uses UTF-8 for encoding text - which is a variant of Unicode. However, Unicode support was only available on PowerPC Macs as of MacOS 8.5, prior to that it was Apple’s own MacRoman encoding. I was able to port a Unix library, libiconv, to the Mac which performs a “best guess” conversion between UTF-8 and MacRoman – so far from my testing it’s been flawless (on English text).

If you’d like to give MacPlayer a go, you’ll need the following:

  1. A Spotify Premium account (only Premium accounts can use Spotify Connect)
  2. A Spotify Connect speaker/device (any modern Mac or PC with Spotify installed can also act as a target device)
  3. A 68k Mac with an Ethernet Card
  4. An OpenWRT wifi router, such as the GL-AR300M. Follow the setup instructions on the MacWifi Readme.
  5. The latest version of the MacWifi Extension.
  6. Then download the MacPlayer app.


Just note that the first version is pretty limited, and probably buggy :)

Looking ahead, I’d like to get the app more functional – and colour monitor support is definitely on the wish list – but for now I’m going to take a break and enjoy the fruits of my labour.

 

nglevin

Well-known member
I am not a Spotify user but those screenshots are super coooool!  :cool:

This was done with Retro68? I should probably be making time to learn to build something with that toolkit.

 

CC_333

Well-known member
This is pretty spiffy!

Any chance you could make it work with Amazon Music as well? Or is the underlying architecture too different?

Maybe on better/higher end 68k Macs and/or OldWorld PPCs, you can allow for the option of playing audio through the computer's built-in sound? It'd likely sound quite bad on the SE/30 with its puny mono speaker, but on a Mac with better sound, it could be passable?

An OpenWRT wifi router, such as the GL-AR300M.
I *really* need to get myself one of these sometime!!

c

 

sambapati87

Well-known member
This is incredible.

Idea: it's probably easier for a lot of people to stand up a small HTTP proxy on their local network that communicates with Spotify over HTTPS, rather than requiring that dedicated WiFI hardware. I think that would allow this to work regardless of how you're getting your TCP/IP party on... the "Spotify API URL" could presumably be added to the preferences of this app to enable something like that?

Would love to see this eventually take advantage slightly more modern Macs (OS 9-era?) with color album art, and possibly fewer workarounds required! This is a perfect excuse to put my Duo w/ Ethernet mini dock into use sitting on top of my receiver :)

Side note: seeing the WiFi antenna sticking out of the back of the SE/30 made my jaw drop. So cool, don't think I've seen that before.

 

techknight

Well-known member
Dude. This could have been a darn good RetroChallenge project. Wow. Impressive. 

But, what is 68k.io? and how is it in involved? 

 
Last edited by a moderator:

nickpunt

Well-known member
@techknight 68k.io is a simple page that hits the Spotify API to grab a short code that you need to confirm your device's authorization. Seems you'd need to be logged into Spotify via your browser and then 68k.io just displays a page to grab the short key to confirm connection. That requires HTTPS & modern web browser as Ants mentioned. It doesn't look like it stores credentials or anything.

 

techknight

Well-known member
@techknight 68k.io is a simple page that hits the Spotify API to grab a short code that you need to confirm your device's authorization. Seems you'd need to be logged into Spotify via your browser and then 68k.io just displays a page to grab the short key to confirm connection. That requires HTTPS & modern web browser as Ants mentioned. It doesn't look like it stores credentials or anything.
Maybe, but I dont see the 68k.io code, so to me, its abstracted so I cant see how it REALLY works. Would be awesome to me to see it so I could understand it better. Because there are gaps here personally I would like to fullfill. 

For a minute, I thought 68k.io was an internal webserver that ran on the openwrt platform or something, but it isnt. its an actual webserver with an actual https cert. 

 
Last edited by a moderator:

ants

Well-known member
Seems with the Oauth flow you've paved the way for a few more services too
I created 2 separate GitHub projects for the OAuth stuff:

Technically these projects should work with any OAuth implementation.

Any chance you could make it work with Amazon Music as well?
There doesn't seem to be much of an API for Amazon Music that I can find. Also, Spotify is the only streaming provider I'm aware of that streams music from the target device - and not from the source device, if that makes sense?

Would this work with an imac G3?
If the imac is running a classic version of MacOS - or OS X with classic support, then maybe? You'd still need an OpenWRT router though.

 
Top