Most apps that play audio eventually want a waveform: voice notes, podcasts, music editors, recorders. Drawing one sounds simple until you need to decode a long file without blocking the UI, keep scrubbing smooth, show detail when the user zooms in, and react to live audio.
I built WaveformKit to handle all of that in one SwiftUI view, with no dependencies. Version 0.8.0 adds Apple Watch and Apple TV, so it now runs on every Apple platform.
The short version
@State private var loader = WaveformLoader ( )
WaveformView ( loader : loader , currentTime : player . currentTime , onSeek : { player . seek ( to : $0 ) } ) . waveformStateOverlay ( loader . state ) . frame ( height : 80 ) . task { loader . load ( url : audioURL ) }
Enter fullscreen mode
Exit fullscreen mode
That decodes the file in the background, shows a loading state, caches the result on disk, and draws the played part as playback moves.…