
Developers
iOS SDK
Developers
iOS SDK
This section gives a brief introduction to the player API in order to help you get quickly started.
The core of the Flowplayer iOS SDK is the FPFlowplayerViewController
which inherits from UIViewController
and can therefore be added to a UIView
or to a UIViewController
in an ordinary fashion like so:
import UIKit
import FlowplayerCore
class PlayerViewController: UIViewController {
@IBOutlet var containerView: UIView!
private let flowplayerViewController = FPFlowplayerViewController()
override func viewDidAppear(_ animated: Bool) {
// Add the FPFlowplayerViewController's view either to a container view or directly to your UIViewController's view.
containerView.addSubview(flowplayerViewController.view)
}
}
You can also add FPFlowplayerViewController
to your Storyboard similar to any other UIViewController
.
FPFlowplayerViewController
can play media either by fetching a so-called Flowplayer config or directly from a media URL that you specify.
In the first scenario, the player needs to be prepared with a Flowplayer mediaId
and a playerId
. This is achieved by preparing the player with a FPFlowplayerMedia
instance, similar to the example below. The player will then fetch the Flowplayer config which contains the media URL, the ad schedule (if any), and branding-related information.
To utilize the Flowplayer Analytics you must use Flowplayer platform mediaids (either videos hosted on our platform or registered remote assets ) Configuring direct stream urls will not trigger Analytics. You must also load the Analytics plugin.
let flowplayerMedia = FPFlowplayerMedia(mediaId: "some-media-id", playerId: "some-player-id")
flowplayerViewController.prepare(flowplayerMedia: flowplayerMedia, autoStart: true)
In a similar way, the player can be prepared with a local or remote media URL. This is possible by preparing the player with an ExternalVideo
instance as shown below.
An FPExternalMedia
may optionally contain an FPAdSchedule
, as well. For more information about ads, see section Advertisement.
let externalMedia = FPExternalMedia(mediaUrl: URL(string: "https://link.to.a.media.file")!)
flowplayerViewController.prepare(externalMedia: externalMedia, autoStart: true)
When playing HLS media you can configure the preferred maximum peak bitrate.
You can achieve this by defining the preferred peak bitrate as a double when constructing the media:
// Flowplayer media
let flowplayerMedia = FPFlowplayerMedia(mediaId: "some-media-id", playerId: "some-player-id", preferredPeakBitRate: 500000)
// ExternalMedia
let externalMedia = FPExternalMedia(mediaUrl: URL(string: "https://link.to.a.media.file.hls")!, preferredPeakBitRate: 500000)
This is offloaded to AVPlayer - see their documentation for gotchas and pitfalls here.
Live streaming
Live analytics
Ad scheduling
Monetization