div # 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. ```swift 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. ```swift 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. ```swift 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: ```swift 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](/docs/wowza-flowplayer/apple-sdk/ios-features/client-side-ad-insertion/) and [tvOS > Client-side ad insertion](/docs/wowza-flowplayer/apple-sdk/tvos-features/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: ```swift 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 embed For more details and configuration information, see [Server-side insertion for iOS](/docs/wowza-flowplayer/apple-sdk/ios-features/server-side-ad-insertion/) or [Server-side insertion for tvOS](/docs/wowza-flowplayer/apple-sdk/tvos-features/server-side-ad-insertion/).