Home

Playtree Technical Overview

Playtree is an application for making and listening to playtrees, which are like playlists, except that playback can branch, loop, and start at multiple entry points. You can try out playtree here. In this post, I’ll provide a broad overview of the Playtree application and its development. The source code is available on GitHub.

Check out the playtree explainers for a more in-depth explanation of playtrees.

At a Glance

alt

Playtree is a web application for creating custom playtrees, which are directed graphs. Playnodes contain songs to be played, and playedges define a path playback can follow.

Key aspects of the project include:

Technical Details

Here, I’ll give a brief outline of Playtree and the tools used to implement Playtree.

Backend

Frontend

Data Model

The central data structure is the Playtree. It is created and updated by the playtree editor, stored as JSON on the server, and used by the player to dictate playback. It includes the following:

To ensure data integrity, I’ve implemented server-side syntax validation using a Go validator library as well as client-side semantic validation.

Key Features

Challenges and Solutions

UI for the Playtree editor

I used React Flow to implement an interactive graph editor. Synchronizing the UI state with the playtree data took a careful approach and a deep understanding of React’s reconciliation algorithm.

See this post for more.

Managing playback logic and state

Managing a playtree’s playback is more involved than it is for an ordinary playlist. Multiple playheads are maintained, playback can loop and randomly branch, and plays on a playnode or playedge can be limited. As a result, implementing the player logic was a complicated task.

See this post for more.

Integrating the Spotify API

Playtree uses the Spotify API to play music. This introduces the need for an authentication scheme. Also, because playback occurs on a Spotify device, it can be altered by other Spotify clients during Playtree playback. It was important to efficiently and comprehensively synchronize the Playtree playback state with the Spotify playback state in real time.

See this post for more.

Conclusion

The Playtree application touched on many key aspects of web development, and offered some specific challenges as well. Now that it’s up and running, I’m pleasantly surprised that such a speculatively designed application could be so fun to use. It even seems like it’ll have its use cases. I look forward to expanding upon and refining Playtree moving forward.