Skip to content

iOS quick start

OGPlayer for iOS is built on AVFoundation with a SwiftUI player view, distributed with Swift Package Manager.

Requirements: iOS 18+ · Swift 5.9+ / Xcode 16+ · SwiftUI for the player view (OGPlayerCore alone works from any iOS app).

In Xcode: File → Add Package Dependencies… and add:

https://github.com/ogplayer-sdk/ogplayer-swift

selecting the products you need:

  • OGPlayerCore — playback engine, DRM, analytics
  • OGPlayerUI — the SwiftUI OGPlayerView with the full control chrome
  • OGPlayerAdsIMA — Google IMA ads (optional)
import OGPlayerCore
@StateObject var player = OGPlayer(licenseKey: "OGP1…") // omit → watermarked trial
if let item = OGMediaItem(
urlString: "https://example.com/stream.m3u8",
title: "My video"
) {
player.load(item)
}

FairPlay content takes a FairPlayConfig (application certificate + license server) with an async tokenProvider invoked on every license request — renewals included:

var drm = FairPlayConfig(
certificateURLString: "https://license.example.com/fairplay.cer",
licenseServerURLString: "https://license.example.com/fairplay"
)!
drm.tokenProvider = { request in
["X-AxDRM-Message": await tokenService.freshToken()]
}
import OGPlayerUI
struct WatchScreen: View {
@StateObject var player = OGPlayer()
@State var isFullscreen = false
var body: some View {
OGPlayerView(
player: player,
isFullscreen: $isFullscreen,
config: OGUIConfig()
)
.aspectRatio(16 / 9, contentMode: .fit)
}
}
player.addListener(myListener) // PlaybackListener — same callbacks as Android
player.addAnalyticsListener(analytics) // AnalyticsEvent — same shapes as Android

Every guide in these docs has a matching screen in the open-source iOS demo app — clone it and lift code from there.