---
title: "iOS video player SDK for Swift apps | Kinescope"
description: "Swift SDK for iOS: a customizable Kinescope player with FairPlay DRM, offline HLS downloads, live streams, AirPlay and picture-in-picture. Install with SPM or CocoaPods."
url: https://kinescope.com/developers/ios-video-player-sdk
---

# iOS video player SDK for Swift apps

Add a Kinescope player to your iOS app in Swift. It plays videos, live streams and FairPlay-protected content from your dashboard, downloads HLS for offline viewing and supports AirPlay and picture-in-picture.

[Start for free](https://app.kinescope.io/user/create?lang=en)[View on GitHub](https://github.com/kinescope/ios-kinescope-player)

## Quick start

Install KinescopeSDK and play your first video. Commands and code are from the package README.

1.  ### Install the SDK

    Add KinescopeSDK with Swift Package Manager, then link your target with the `KinescopeSDK` product. CocoaPods works too: `pod 'KinescopeSDK', '~> 0.2'`.

    Package.swift

    ```
    dependencies: [
        .package(url: "https://github.com/kinescope/ios-kinescope-player.git", exact: "0.2")
    ]
    ```

2.  ### Configure the SDK at startup

    Initialize the SDK once, for example in your app delegate.

    swift

    ```
    Kinescope.shared.setConfig(.init())
    ```

3.  ### Create a player and attach a view

    Create a player with the video ID and connect it to `KinescopePlayerView`. All controls are already in the view and can be hidden.

    swift

    ```
    let player = KinescopePlayer(videoId: "yourVideoId")

    let playerView = KinescopePlayerView()
    view.addSubview(playerView)

    player.attach(view: playerView)
    ```


## What is in the iOS SDK

### FairPlay DRM out of the box

The player decodes FairPlay-protected video and talks to the key server itself. Any DRM video from your dashboard plays without extra setup.

### Offline downloads

`VideoDownloader` saves HLS videos with `AVAssetDownloadURLSession`, with pause, resume, cancel and progress events. Separate downloaders handle files and attachments.

### AirPlay, PiP and background audio

AirPlay and picture-in-picture work out of the box; with the background mode on, audio keeps playing when the app goes to the background.

### Live streams

`KinescopePlayerView` shows a live indicator and an announcement with the planned start time.

### Customizable player view

Configure the options menu, control panel, overlays, side menu and error overlay, or hide what you do not need. Strings can be localized.

### Error handling and analytics

On errors the player retries 10 times with a 5-second delay before showing a refresh button. Playback events go to Kinescope analytics automatically.

## AVPlayer on its own vs the Kinescope SDK

What you would build around Apple’s player yourself, and what the SDK already does.

|  | AVPlayer on its own | Kinescope iOS SDK |
| --- | --- | --- |
| HLS and live playback | ✓ built in | ✓ with live indicator and announcement |
| Hosting, transcoding and CDN | ✗ your own backend | ✓ Kinescope platform |
| FairPlay DRM | ✓ key session and key server are yours | ✓ key server exchange built in |
| Customizable player UI | ✗ AVPlayerViewController or your own controls | ✓ KinescopePlayerView with options menu |
| Offline HLS downloads | ✓ AVAssetDownloadURLSession; you manage the queue | ✓ VideoDownloader with pause, resume and events |
| Error retries | ✗ build it yourself | ✓ 10 retries, then a refresh button |
| Viewing analytics | ✗ your own pipeline | ✓ sent to Kinescope automatically |

AVPlayer on its own

HLS and live playback

✓ built in

Hosting, transcoding and CDN

✗ your own backend

FairPlay DRM

✓ key session and key server are yours

Customizable player UI

✗ AVPlayerViewController or your own controls

Offline HLS downloads

✓ AVAssetDownloadURLSession; you manage the queue

Error retries

✗ build it yourself

Viewing analytics

✗ your own pipeline

Kinescope iOS SDK

HLS and live playback

✓ with live indicator and announcement

Hosting, transcoding and CDN

✓ Kinescope platform

FairPlay DRM

✓ key server exchange built in

Customizable player UI

✓ KinescopePlayerView with options menu

Offline HLS downloads

✓ VideoDownloader with pause, resume and events

Error retries

✓ 10 retries, then a refresh button

Viewing analytics

✓ sent to Kinescope automatically

## The platform behind the SDK

### Upload and transcoding

Upload through the dashboard, the API or resumable TUS upload. Every video is encoded into adaptive renditions up to 4K. [Video hosting](https://kinescope.com/products/video-hosting)

### Own CDN

Kinescope delivers the streams your app plays from its own CDN, with points of presence in Latin America, the United States, Europe and the CIS. [Video CDN](https://kinescope.com/products/content-delivery-network)

### DRM on the Super plan

Widevine and FairPlay licenses are included on the Super plan. Your backend can approve each play. [DRM video hosting](https://kinescope.com/solutions/video-hosting-drm)

### Live streams

Send RTMP or sRTMP from OBS, vMix or a hardware encoder and keep an automatic recording. The SDK players show the stream live. [Live streaming](https://kinescope.com/products/streaming)

### Analytics

Views, watch depth and drop-off points for every video. Pass your user ID from the app to see data per viewer. [Video analytics](https://kinescope.com/products/video-analytics)

### Pay as you go

Start on the free plan with 100 minutes of video and 200 GB of traffic a month. Paid usage: storage and delivery from €0.03/GB, processing €0.01/min. [Pricing](https://kinescope.com/pricing)

## Documentation

Every guide for this SDK in its repository, on GitHub.

### Player view

-   [Customization](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#playerview-customisation)
-   [Options menu](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#managing-of-options-menu)
-   [Configuration parameters](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#configuration-parameters)

### Downloads

-   [HLS video downloader](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#kinescopevideodownloadable-and-videodownloader)
-   [File downloader](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#kinescopeassetdownloadable-and-assetdownloader)
-   [Attachments](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#kinescopeattachmentdownloadable-and-attachmentdownloader)

### DRM

-   [FairPlay Streaming](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#fairplaystreaming-drm-protected-content)
-   [Offline FairPlay example](https://github.com/kinescope/ios-fairplay-offline)

### Playback

-   [AirPlay, PiP and background mode](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#airplay-picture-in-picture-and-background-mode)
-   [Live streams](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#live-streams)

### App integration

-   [Localization](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#localization)
-   [Error handling](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#error-handling)
-   [Analytics](https://github.com/kinescope/ios-kinescope-player/blob/master/DOCUMENTATION.md#analytics)

### Project

-   [Example project](https://github.com/kinescope/ios-kinescope-player/tree/master/Example)
-   [Changelog](https://github.com/kinescope/ios-kinescope-player/blob/master/CHANGELOG.md)

## FAQ

Can’t find the answer you need? Check out our [All developer tools](https://kinescope.com/developers).

With Swift Package Manager, add the ios-kinescope-player repository and link the KinescopeSDK product. With CocoaPods, add pod 'KinescopeSDK', '~> 0.2' to your Podfile.

Yes. FairPlay decoding, including the key server exchange, is built into KinescopePlayer, so DRM videos from your dashboard play without changes. For offline DRM, the ios-fairplay-offline example shows persistent FairPlay keys in SwiftUI.

Yes. After configuration you can play any video or live stream from your Kinescope dashboard.

MIT. The SDK is free; you pay only for Kinescope hosting and delivery.
