In the Playback section we list the common features shared by all player engines (PlayerEngine.apple)
Basic playback
An example project of basic HLS playback is provided as part of the PRESTOPlay SDK. The example is located in the Examples folder and can be opened with Xcode.
// Initialise the SDK and register the plugins
_ = PRESTOPlaySDK.shared.register("LICENSE",[HLSPlugin()])
// Create the player
var player = PRESTOPlaySDK.shared.player()
guard let contentURL = URL(string: "https://example.com/master.m3u8")
else { return }
// Configure the player
let config = PlayerConfiguration(with: contentURL)
player.load(config: config)
player.onState = { previous, state in
// Handle player state changes
switch state.playbackState {
case .ready:
print("Player ready")
// handle other states ...
}
if let error = state.playerError {
print("Error \(error)")
}
}
// Attach the player to the view
player.attach(to: view.layer)
// Start playback
player.open(autoplay: true)
Video gravity
Video gravity determines how the video content is scaled or stretched within the player bounds.
The player layer supports the following video gravity values:
AVLayerVideoGravity.resizeAspectplayer should preserve the video’s aspect ratio and fit the video within the bounds,


AVLayerVideoGravity.resizeAspectFillplayer should preserve the video’s aspect ratio and fill the bounds,


AVLayerVideoGravity.resizevideo should be stretched to fill the bounds

