HLS

HLS playback is supported by our player engine with some key differences.

PlayerEngine.apple

  • based on AVPlayer and other AVFoundation framework classes

  • support for FairPlay Streaming and AirPlay

  • no advanced tuning settings

HLSSettings

HLSPlugin can be instantiated with HLSSettings during SDK setup, for example in AppDelegate.

import UIKit
import PRESTOplay
import CastlabsApple

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
    ) -> Bool {
        let hlsSettings = HLSSettings(
            hlsPlayerDefaultPropertiesToLoad: [
                .playable,
                .tracks,
                .availableMediaCharacteristicsWithMediaSelectionOptions,
                .protectedContent,
                .variants,
                .commonMetadata,
            ],
            hlsDownloaderDefaultPropertiesToLoad: [
                .tracks,
                .availableMediaCharacteristicsWithMediaSelectionOptions,
                .commonMetadata,
            ]
        )

        _ = PRESTOplaySDK.shared.setup("LICENSE", [HLSPlugin(hlsSettings)])
        return true
    }
}

HLSSettings controls which AssetPropertiesManager.Property values are loaded up front for the Apple HLS player and downloader.

  • hlsPlayerDefaultPropertiesToLoad: properties preloaded for HLSPlayer
  • hlsDownloaderDefaultPropertiesToLoad: properties preloaded for HLSDownloader

If you omit one of these parameters, the SDK uses the default list for that component. Passing an explicit array overrides the default for that side only.

Default player properties:

[.playable, .tracks, .availableMediaCharacteristicsWithMediaSelectionOptions, .protectedContent, .variants]

Default downloader properties:

[.tracks, .availableMediaCharacteristicsWithMediaSelectionOptions]

The older HLSSettings(defaultPropertiesToLoad:) initializer applies the same list to both player and downloader, but it is deprecated. Prefer the player-specific and downloader-specific initializer shown above.

Available property options

You can use any AssetPropertiesManager.Property case in these arrays:

  • .availableChapterLocales: loads available chapter locales
  • .playable: loads whether the asset is playable
  • .composable: loads whether the asset can be composed with other assets
  • .exportable: loads whether the asset can be exported
  • .readable: loads whether the asset can be read
  • .tracks: loads the asset tracks
  • .availableMediaCharacteristicsWithMediaSelectionOptions: loads available media characteristics for audio, subtitles, and other selectable media
  • .availableMetadataFormats: loads the available metadata formats
  • .commonMetadata: loads common metadata entries
  • .creationDate: loads the asset creation date
  • .duration: loads the asset duration
  • .protectedContent: loads whether the asset contains protected content
  • .lyrics: loads lyrics metadata
  • .metadata: loads the full metadata collection
  • .preferredRate: loads the preferred playback rate
  • .preferredVolume: loads the preferred playback volume
  • .allMediaSelections: loads all media selections for URL-based assets
  • .providesPreciseDurationAndTiming: loads whether the asset provides precise duration and timing for URL-based assets
  • .variants: loads HLS variants for non-offline URL-based assets

For best startup behavior, only preload the properties your application needs immediately. Some properties are only available for URL-based assets, and .variants is not available for offline HLS content.

Picture in Picture

Picture in Picture is the ability to keep watching your video while interacting with other apps.

Due to Apple restrictions, the feature is currently available only for HLS streams played with PlayerEngine.apple.

Although not exactly similar to the real Picture in Picture, you can enable one of these modes for the ViewController containing our Player View.

For more details on “Multitasking on iOS”: https://support.apple.com/en-us/HT202070

You can use Picture in Picture with iPad Pro, iPad Air and later, and iPad mini 2 and later.

Make sure to enable the Audio, AirPlay, and Picture in Picture background mode among your app capabilities.

High Efficiency Video Coding (HEVC/H.265)

Our player supports HLS streams with HEVC encoded media.

HLS playback with PlayerEngine.apple is limited to devices set with a processor newer or equal to A9 (iPhone 7 and above). Software decoding using AVFoundation is possible on all iOS/iPadOS devices. Our tests found that HEVC media is not playable on iPhone 6 devices.

For list of iOS/iPadOS devices supporting HEVC playback please view (this list may not be complete, Capturing this media): https://support.apple.com/en-us/HT207022

For list of iOS/iPadOS devices supporting HEVC software decoding please visit (Working with this media): https://support.apple.com/en-us/HT207022#working

Apple distinguishes decodable from playable content. Source:

https://devstreaming-cdn.apple.com/videos/wwdc/2017/503i6plfvfi7o3222/503/503_introducing_heif_and_hevc.pdf

https://developer.apple.com/videos/play/wwdc2017/503/