This page describes setting up and configuring the player within your iOS or tvOS application. When you incorporate the player using the SDK framework and its API, you can use its powerful features to enhance the playback experience for your users.
Applies to: iOS
At the core of the iOS component of the Apple SDK is the FlowplayerView class, an implementation of the FlowplayerViewAPI protocol that provides a view component for the media player. When using this class, you can render the player within your user interface, and handle user interactions and visual customizations.
The FlowplayerView class extends the UIView object and manages content for a rectangular screen area. Since the FlowplayerView class inherits from the UIView object, it can be added to a UIView or UIViewController, as demonstrated in the examples in this section.
You can use this sample code to set up, load, and utilize the FlowplayerView using Storyboard.
import UIKit
import FlowplayerSDK
class MyViewController: UIViewController {
@IBOutlet weak var flowplayerView: FlowplayerView!
override func viewDidLoad() {
super.viewDidLoad()
flowplayerView.load(...)
}
}This example illustrates how to set up, load, and use the FlowplayerView using a programmatic approach.
import UIKit
import FlowplayerSDK
class MyViewController: UIViewController {
private let flowplayerView = FlowplayerView()
override func viewDidLoad() {
super.viewDidLoad()
// Set up the view
view.addSubview(flowplayerView)
flowplayerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
flowplayer.centerXAnchor.constraint(equalTo: view.centerXAnchor),
flowplayer.centerYAnchor.constraint(equalTo: view.centerYAnchor),
flowplayer.heightAnchor.constraint(equalToConstant: 250),
flowplayer.leadingAnchor.constraint(equalTo: view.leadingAnchor),
flowplayer.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
// Use the view
flowplayerView.load(...)
}
}Applies to: tvOS
At the core of the tvOS component of the Apple SDK is the FlowplayerManager object, which manages media playback, media assets, playback state, player state, and advertisements. You can think of this object as the manager of your AVPlayer instance. It wraps around the player and provides the methods and properties to manage your player instance.
With the following example, you can incorporate the player into your tvOS application using the FlowplayerManager class.
import UIKit
import FlowplayerSDK
class MyViewController: UIViewController {
private var manager: FlowplayerManager
private let player = AVPlayer()
private let playerController = AVPlayerViewController()
override func viewDidLoad() {
super.viewDidLoad()
manager = FlowplayerManager(avPlayer: player)
present(playerController, animated: false) {
self.manager.load(...)
}
}
}Applies to: iOS and tvOS
To work with the player in your iOS or tvOS application, you must define how the player loads media files. You can leverage the FlowplayerAPI class and the MediaExternal, MediaOVP, or MediaDAI structures to load different media types.
You can play media directly from a specific media URL by configuring the player to use a local or remote resource. To load external media, initialize the player with an MediaExternal instance as shown in the following example:
let externalMedia = MediaExternal(url: URL(string: "https://link.to.a.media.file")!)
let player.load(external: externalMedia)These properties are available when working with a MediaExternal structure.
| Property | Description |
|---|---|
adScheduleObject | Optional ad schedule to display ads during external media playback. For more information about using ad schedules with external media, see iOS > Client-side ad insertion and tvOS > Client-side ad insertion. |
preferredPeakBitRateDouble | Optional Double representing the preferred peak bitrate for the media item's playback. If not provided, the default bitrate is used. |
urlString | URL representing the location of the external media item. |
You can configure your player to load video content from the Wowza Video platform. To load this media, initialize the player using a MediaOVP instance as shown in the following example. This example includes sample values that you must replace with your own media ID and player configurations:
let platformMedia = MediaOVP(mediaId: "[your-media-id]", playerId: "[player-configuration-id]")
let player.load(ovp: platformMedia)These properties are available when working with a MediaOVP structure.
| Property | Description |
|---|---|
mediaIdString | Represents the unique identifier of the VOD or live stream asset in Wowza Video. See ID information for VOD content or live stream content in Wowza Video. |
playerIdString | Represents the unique identifier of the player configuration to be used from Wowza Video. See player configuration details in Wowza Video. |
preferredPeakBitRateDouble | Optional Double representing the preferred peak bitrate for the media item's playback. If not provided, the default bitrate is used. |
For more details and configuration information, see Server-side insertion for iOS or Server-side insertion for tvOS.