Menu

One SwiftUI waveform view for iPhone, Apple Watch and Apple TV
📰

One SwiftUI waveform view for iPhone, Apple Watch and Apple TV

DEV Community: swift·Chethan Nayak·6 days ago
#m1XD32De
#devtoswift#devto#dev#apple#loader
Long article (399 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.