Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud Video
    • Overview
    • Control
      • Overview
        • Getting started
    • Browser autoplay policy
  • Access management
  • Pricing policy
  • Audit Trails events
  • Release notes
  • Troubleshooting

In this article:

  • Adding a video player SDK library
  • Importing the libraries
  • Using the SDK
  • Set up the start of playback
  • Connecting a video player skin
  • Playback in SwiftUI
  • Configuring playback
  • Monitoring the player state
  • Returning to live
  1. Video Player
  2. SDK
  3. iOS
  4. Getting started

Video player SDK for iOS

Written by
Yandex Cloud
Updated at November 5, 2026
View in Markdown
  • Adding a video player SDK library
  • Importing the libraries
  • Using the SDK
    • Set up the start of playback
    • Connecting a video player skin
    • Playback in SwiftUI
    • Configuring playback
    • Monitoring the player state
    • Returning to live

The SDK allows you to embed a player for Cloud Video content into your iOS app.

To use the SDK, you need the Xcode IDE version 16.4 or higher and Swift version 5.10 or higher. Minimum supported iOS version: 15.

Adding a video player SDK libraryAdding a video player SDK library

Xcode SPM
Package.swift
  1. In the Project Navigator Xcode window, select your project.

  2. In the top panel, click File and select Add Package Dependencies....

  3. In the search box , enter https://github.com/yandex-cloud/cloud-video-player-ios-sdk/. Then, select the cloud-video-player-ios-sdk package.

  4. In the Dependency Rule field, select Up to Next Major Version and specify the version: 0.1.7.

  5. In the Add to Project field, select the project you want to add libraries to and click Add Package.

  6. In the pop-up window, specify the target to add the libraries to and click Add Package.

    The package contains the following libraries:

    • CloudVideoPlayer: Main library of the video player SDK for iOS.
    • CloudVideoPlayerUI: Additional library with a collection of interface elements (video player skin).
  1. In the Project Navigator Xcode window, select your project.

  2. Open Package.swift.

  3. Add the following dependency to the dependencies array:

    dependencies: [
      .package(
        url: "https://github.com/yandex-cloud/cloud-video-player-ios-sdk/",
        from: "0.1.7"
      )
    ],
    
  4. Add the libraries to the dependencies array of the target:

    .target(
      name: "MyTargetName",
      dependencies: [
        .product(name: "CloudVideoPlayer", package: "cloud-video-player-ios-sdk"),
        .product(name: "CloudVideoPlayerUI", package: "cloud-video-player-ios-sdk")
      ]
    ),
    

    Where:

    • CloudVideoPlayer: Main library of the video player SDK for iOS.
    • CloudVideoPlayerUI: Additional library with a collection of interface elements (video player skin).
  5. Save your changes.

Importing the librariesImporting the libraries

To import the libraries, add the following lines to your code file:

import CloudVideoPlayer
import CloudVideoPlayerUI

Using the SDKUsing the SDK

Set up the start of playbackSet up the start of playback

  1. Import a library in the file:

    import CloudVideoPlayer
    
  2. Create the Configuration, Environment, and YaPlayer objects:

    let environment = Environment(configuration: Configuration(from: From(raw: "your-app-bundle")))
    
    class ViewController: UIViewController {
      let player = environment.player()
    }
    
  3. Create the VideoSurface UIView component, add it to the hierarchy, and attach to the player instance:

    let surface = VideoSurface()
    
    override func loadView() {
      super.loadView()
      self.view.addSubview(surface)
      surface.frame = UIScreen.main.bounds
    }
    
    override func viewDidLoad() {
      super.viewDidLoad()
      surface.attach(player: player)
    }
    
  4. Start playback:

    if let source = ContentIdEndpoint(url: URL(string: "https://runtime.video.cloud.yandex.net/player/...")!) {
      player.set(source: source)
      player.play()
    }
    

Where https://runtime.video.cloud.yandex.net/player/... is a link to a video, broadcast, or playlist.

Full code to set up the start of playback
import CloudVideoPlayer

let environment = Environment(configuration: Configuration(from: From(raw: "your-app-bundle")))

class ViewController: UIViewController {

  let player = environment.player()
  let surface = VideoSurface()

  override func loadView() {
    super.loadView()
    self.view.addSubview(surface)
    surface.frame = UIScreen.main.bounds
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    surface.attach(player: player)

    if let source = ContentIdEndpoint(url: URL(string: "https://runtime.video.cloud.yandex.net/player/...")!) {
      player.set(source: source)
      player.play()
    }
  }
}

Where https://runtime.video.cloud.yandex.net/player/... is a link to a video, broadcast, or playlist.

Connecting a video player skinConnecting a video player skin

  1. Import a library in the file:

    import CloudVideoPlayerUI
    
  2. Create the VideoView UIView component, add it to the hierarchy, and connect to the player instance:

    let videoView = VideoView()
    
    override func loadView() {
      super.loadView()
      self.view.addSubview(videoView)
      videoView.frame = UIScreen.main.bounds
    }
    
    override func viewDidLoad() {
      super.viewDidLoad()
      videoView.attach(player: player)
    }
    
Full code to connect a video player skin
import CloudVideoPlayerUI

let videoView = VideoView()

override func loadView() {
  super.loadView()
  self.view.addSubview(videoView)
  videoView.frame = UIScreen.main.bounds
}

override func viewDidLoad() {
  super.viewDidLoad()
  videoView.attach(player: player)
}

Playback in SwiftUIPlayback in SwiftUI

To embed your player in SwiftUI, wrap VideoView from CloudVideoPlayerUI into UIViewRepresentable, then bind it to the YaPlayer instance created via Environment.

  1. Import these libraries in the file:

    import SwiftUI
    import CloudVideoPlayer
    import CloudVideoPlayerUI
    
  2. Create the Environment and YaPlayer objects:

    let environment = Environment(configuration: Configuration(from: From(raw: "your-app-bundle")))
    
    final class PlayerViewModel: ObservableObject {
      let player: YaPlayer = environment.player()
    
      init() {
        guard
          let url = URL(string: "https://runtime.video.cloud.yandex.net/player/..."),
          let source = ContentIdEndpoint(url: url)
        else {
          return
        }
        player.set(source: source)
        player.play()
      }
    }
    
  3. Create the UIViewRepresentable type that creates your VideoView and calls attach(player:):

    struct VideoViewRepresentable: UIViewRepresentable {
      let player: YaPlayer
    
      func makeUIView(context: Context) -> VideoView {
        let view = VideoView()
        view.attach(player: player)
        return view
      }
    
      func updateUIView(_ uiView: VideoView, context: Context) {
        uiView.attach(player: player)
      }
    }
    
  4. Add the wrapper to the SwiftUI hierarchy:

    struct ContentView: View {
      @StateObject private var viewModel = PlayerViewModel()
    
      var body: some View {
        VideoViewRepresentable(player: viewModel.player)
          .aspectRatio(16 / 9, contentMode: .fit)
          .frame(maxHeight: .infinity, alignment: .top)
      }
    }
    

Where https://runtime.video.cloud.yandex.net/player/... is a link to a video, broadcast, or playlist.

Full code for playback in SwiftUI
import SwiftUI
import CloudVideoPlayer
import CloudVideoPlayerUI

let environment = Environment(configuration: Configuration(from: From(raw: "your-app-bundle")))

final class PlayerViewModel: ObservableObject {
  let player: YaPlayer = environment.player()

  init() {
    guard
      let url = URL(string: "https://runtime.video.cloud.yandex.net/player/..."),
      let source = ContentIdEndpoint(url: url)
    else {
      return
    }
    player.set(source: source)
    player.play()
  }
}

struct VideoViewRepresentable: UIViewRepresentable {
  let player: YaPlayer

  func makeUIView(context: Context) -> VideoView {
    let view = VideoView()
    view.attach(player: player)
    return view
  }

  func updateUIView(_ uiView: VideoView, context: Context) {
    uiView.attach(player: player)
  }
}

struct ContentView: View {
  @StateObject private var viewModel = PlayerViewModel()

  var body: some View {
    VideoViewRepresentable(player: viewModel.player)
      .aspectRatio(16 / 9, contentMode: .fit)
      .frame(maxHeight: .infinity, alignment: .top)
  }
}

Where https://runtime.video.cloud.yandex.net/player/... is a link to a video, broadcast, or playlist.

Configuring playbackConfiguring playback

To specify the initial position, audio state, and automatic playback start, provide a PlaybackConfig object to the set(source:config:) method:

let config = PlaybackConfig(
  autoplay: true,
  isMuted: false,
  startPosition: Time(sec: 30)
)
player.set(source: source, config: config)

In the example, player is an earlier created YaPlayer instance, and source is a ContentIdEndpoint source. The player will start playback from the 30-second mark, with sound on. If no config is specified, the following PlaybackConfig.base configuration is used: playback from the beginning, not muted, no automatic start.

To change the playback speed, check its availability using the canSet(playbackSpeed:) method, then call set(playbackSpeed:):

if player.canSet(playbackSpeed: .x150) {
  do {
    try player.set(playbackSpeed: .x150)
  } catch {
    print("Failed to change speed: \(error)")
  }
}

For predefined speed values, see the PlaybackSpeed reference.

Monitoring the player stateMonitoring the player state

To receive notifications about changes in the player's state, subscribe to events using Combine. For example, create an object that tracks the player's state, playback position, and errors:

import Combine
import CloudVideoPlayer

final class PlayerObserver {
  private var subscriptions = Set<AnyCancellable>()

  init(player: YaPlayer) {
    player.playerStatusDidChange()
      .sink { status in
        print("Player state: \(status)")
      }
      .store(in: &subscriptions)

    player.periodicTimePublisher(interval: 1)
      .sink { time in
        print("Playback position: \(time)")
      }
      .store(in: &subscriptions)

    player.errorDidDetected()
      .sink { error in
        print("Playback error: \(error)")
      }
      .store(in: &subscriptions)
  }
}

Create a PlayerObserver(player: player) instance and store it, e.g., in a controller property. Subscriptions must be maintained while you are tracking events. Releasing an object cancels its associated subscriptions. By default, events are delivered to the .main queue. To select a different queue, provide the queue parameter to the subscription method.

For the full list of properties and methods, see the YaPlayer reference.

Returning to liveReturning to live

To return to live after rewinding the broadcast, call the goToLive() asynchronous method:

Task {
  do {
    try await player.goToLive()
  } catch {
    print("Failed to return to live: \(error)")
  }
}

The method moves the playback position to the right edge of the broadcast timeline. If the transition is not possible, e.g., during video-on-demand (VOD) playback, the method returns an error.

Useful linksUseful links

SDK library references:

  • CloudVideoPlayer: Main library with Environment, YaPlayer, and VideoSurface objects and playback settings.
  • CloudVideoPlayerUI: Additional UI component library with a ready-made VideoView player shell.

Was the article helpful?

Previous
Player events
Next
Environment
© 2026 Direct Cursus Technology L.L.C.