Swiftpack.co - apivideo/api.video-swift-player as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by apivideo.
apivideo/api.video-swift-player v1.0.5
The official iOS player for api.video
⭐️ 8
🕓 2 weeks ago
iOS macOS
.package(url: "https://github.com/apivideo/api.video-swift-player.git", from: "v1.0.5")

badge   badge   badge

api.video Swift player

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.

Table of contents

Project description

Easily integrate a video player for videos from api.video in your iOS application.

Getting started


Swift Package Manager

In the Project Navigator select your own project. Then select the project in the Project section and click on the Package Dependencies tab. Click on the "+" button at the bottom. Paste the below url on the search bar on the top right. Finaly click on "Add package" button.


Or add this in your Package.swift

  dependencies: [
        .package(url: "https://github.com/apivideo/api.video-swift-player.git", from: "1.0.5"),


Add pod 'ApiVideoPlayer', '1.0.5' in your Podfile

Run pod install

Retrieve your video Id

At this point, you must have uploaded a least one video to your account. If you haven't see how to upload a video. You'll need a video Id to use this component and play a video from api.video. To get yours, follow these steps:

  1. Log into your account or create one here.
  2. Copy your API key (sandbox or production if you are subscribed to one of our plan).
  3. Go to the official api.video documentation.
  4. Log into your account in the top right corner. If it's already done, be sure it's the account you want to use.
  5. Go to API Reference -> Videos -> List all videos
  6. On the right, be sure the "Authentication" section contains the API key you want to use.
  7. Generate your upload token by clicking the "Try It!" button in the right section
  8. Copy the "videoId" value of one of elements of the response in the right section.

Alternatively, you can find your video Id in the video details of your dashboard.

Code sample

  1. Import the library
import ApiVideoPlayer
  1. Instantiate the Player view with the player events:
    let playerView: ApiVideoPlayerView = {
        let events = PlayerEvents(
            didPause: {() in
            didPlay: {() in
            didReplay: {() in
                print("video replayed")
            didLoop: {() in
                print("video replayed from loop")
            didSetVolume: {(volume) in
                print("volume set to : \(volume)")
            didSeek: {(from, to)in
                print("seek from : \(from), to: \(to)")
        return ApiVideoPlayerView(frame: .zero, videoId: "YOUR_VIDEO_ID", videoType: VideoType.vod /* only .vod is supported */, events: events)
  1. Implement it in your view controller
    override func viewDidLoad() {
  1. To use full screen and subtitle
    override func viewDidAppear(_ animated: Bool) {
        playerView.viewController = self

Sample application

A demo application demonstrates how to use player. See /example folder.

On the first run, you will have to set your video Id:

  1. Replace "YOUR_VIDEO_ID" by your video Id



We are using external library

ApiVideoPlayerAnalytics README.md


If you have any questions, ask us here: https://community.api.video. Or use Issues.


Stars: 8
Last commit: 23 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 weeks ago
  • Add didReady event
  • Use completionhandler in seek method to get the result of the seek, before doing any other action.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics