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).
1 · Add the package
Section titled “1 · Add the package”In Xcode: File → Add Package Dependencies… and add:
https://github.com/ogplayer-sdk/ogplayer-swiftselecting the products you need:
OGPlayerCore— playback engine, DRM, analyticsOGPlayerUI— the SwiftUIOGPlayerViewwith the full control chromeOGPlayerAdsIMA— Google IMA ads (optional)
2 · Build a player and load media
Section titled “2 · Build a player and load media”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()]}3 · Show the player
Section titled “3 · Show the player”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) }}4 · Listen
Section titled “4 · Listen”player.addListener(myListener) // PlaybackListener — same callbacks as Androidplayer.addAnalyticsListener(analytics) // AnalyticsEvent — same shapes as AndroidComplete examples
Section titled “Complete examples”Every guide in these docs has a matching screen in the open-source iOS demo app — clone it and lift code from there.