Amplitude's Streaming Analytics SDK for Apple platforms. It reports what your users watch as Amplitude events.
Alpha. This SDK is ready to use in production, but nothing in it is final. The public API, the internal behaviour, and the events it sends can all change before GA.
If you have any issues using our SDK, feel free to create a GitHub issue or submit a request on Amplitude Help.
iOS 13.0+, tvOS 13.0+, and macOS 10.15+. Requires Amplitude-Swift 1.18.6 or later.
Swift Package Manager. There are no tagged releases during the Alpha, so pin a commit SHA:
dependencies: [
.package(url: "https://github.com/amplitude/AmplitudeStreamingAnalytics-Swift.git", revision: "<commit-sha>")
]Add the plugin to your Amplitude instance once, then track each player you create.
import AVFoundation
import AmplitudeSwift
import AmplitudeStreamingAnalytics
// At startup.
let amplitude = Amplitude(configuration: Configuration(apiKey: API_KEY))
let streaming = StreamingAnalyticsPlugin()
amplitude.add(plugin: streaming)
// For each video. Create the player and give it an item before you track it.
let player = AVPlayer(url: videoURL)
streaming.trackPlayer(player: player, content: PlayerContent(contentId: "ep-42", title: "Pilot"))
player.play()
// When the viewer is done.
streaming.stopTracking(player: player)You can skip stopTracking(player:) if the player is about to go away. The SDK holds the player
weakly and closes the viewing when it deallocates.
See docs/ for the full reference.