Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2021 Spatial ComputingAudio & Video

WWDC21 · 15 min · Spatial Computing / Audio & Video

Explore ShazamKit

Take advantage of Shazam’s exact audio matching capabilities within your app when you use ShazamKit. Learn how you can harness the immense Shazam catalog to create all sorts of experiences, including quickly recognizing the exact song playing in the background of a video captured by your app, offering dynamic visual effects based on the music playing in a room, or even syncing with external audio to provide companion app experiences. We’ll also show you how you can build custom catalogs within ShazamKit to match with any audio source — all on device. For a deeper dive, check out “Create custom audio experiences with ShazamKit,” where you’ll code along with us and learn how to build an education app that synchronizes perfectly with streamed video content.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 3 snippets

Matching signatures using SHSession swift · at 9:11 ↗
// Matching signatures using SHSession
let session = SHSession()
session.delegate = self

let signatureGenerator = SHSignatureGenerator()
try signatureGenerator.append(buffer, at: nil)

let signature = signatureGenerator.signature()
session.match(signature)
Receive matches via session delegate swift · at 10:45 ↗
// Receiving matches via the session delegate
extension SongResultViewController: SHSessionDelegate {
    
    public func session(_ session: SHSession, didFind match: SHMatch) {
        
        guard let matchedMediaItem = match.mediaItems.first else {
            return
        }
        
        DispatchQueue.main.async {
            self.songView.titleLabel.text = matchedMediaItem.title
            self.songView.artistLabel.text = matchedMediaItem.artist
        }
       
    }
}
Add to Shazam library swift · at 12:24 ↗
// Adding to a customer’s library
guard let matchedMediaItem = match.mediaItems.first else {
    return
}

SHMediaLibrary.default.add([matchedMediaItem]) { error in
    
    if error != nil {
        
        // handle the error
    }
        
}

Resources