api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
This library send player events from the player to api.video.
Add the following dependency to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/apivideo/api.video-swift-player-analytics.git", from: "2.0.0"),
],
Add the following line to your Podfile
:
pod 'ApiVideoPlayerAnalytics', '~> 2.0.0
Then, run pod install
.
Create a ApiVideoAnalyticsAVPlayer
instance.
import ApiVideoPlayerAnalytics
let player = ApiVideoAnalyticsAVPlayer(url: "URL of the HLS manifest") // HLS manifest from api.video. Example: https://vod.api.video/vod/YOUR_VIDEO_ID/hls/manifest.m3u8
Then, use it like a regular AVPlayer
.
player.play()
For a custom domain collector, use:
let player = ApiVideoAnalyticsAVPlayer(url: "URL of the HLS manifest", collectorUrl: "https://collector.mycustomdomain.com") // Register the player analytics listener so it sends player events to api.video.
Open ApiVideoPlayerAnalytics.xcodeproj
.
Replace the default media ID in Examples/iOS/ViewController.swift
with your own.
let url = Utils.inferManifestURL(mediaId: "vi77Dgk0F8eLwaFOtC5870yn") // replace `vi77Dgk0F8eLwaFOtC5870yn` with your own media ID
Then, run the Example iOS
target.
If you have any questions, ask us in the community or use issues.