Set up the player with the Wowza Flowplayer Apple SDK
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.
Add the player
iOS projects
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.
Add FlowplayerView using Storyboard
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(...)
}
}
Add FlowplayerView programmatically
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(...)
}
}
tvOS projects
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(...)
}
}
}
Load your media files
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.
Add external media
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 |
---|---|
adSchedule Object |
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. |
preferredPeakBitRate Double |
Optional Double representing the preferred peak bitrate for the media item's playback. If not provided, the default bitrate is used. |
url String |
URL representing the location of the external media item. |
Add Wowza Video media
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 |
---|---|
mediaId String |
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. |
playerId String |
Represents the unique identifier of the player configuration to be used from Wowza Video. See player configuration details in Wowza Video. |
preferredPeakBitRate Double |
Optional Double representing the preferred peak bitrate for the media item's playback. If not provided, the default bitrate is used. |
Add DAI media
The MediaDAI
structure allows you to work with Google's Interactive Media Ads Dynamic Ad Insertion (IMA DAI) SDK to inject server-side ads into your player. We support both of Google's Full service and Pod serving DAI solutions. You can use these Google IMA sample streams when testing HLS streams with your workflows.
To successfully load DAI media, leverage the MediaDAI
structure and types in the following table when initializing the player.
Parameters | Description |
---|---|
stream object |
Defines the stream content to be played. Can be used with the following types:
|
For more details and configuration information, see Server-side insertion for iOS or Server-side insertion for tvOS.