Skip to main content

Apple Player configuration

What you learn​

You're instantiating DIVA Player in your app (mobile/TV) and relying on DIVA Back Office as the video streaming source.

The goal of this article is to build the simplest front-end to stream a video from the DIVA Back Office, having the possibility to control and modify AVPlayer parameters dynamically and remotely.

Before starting​

  • Ensure the DIVA Back Office instance you rely on is up and running.
  • Ask your video engineers team <videoId>, <settingsURL>, <languageCountryCode>, <userToken> and <sharedKey>.
  • Ensure the settings file contains the applePlayerConfiguration fields.

Instantiation iOS logo​

The Basic instantiation code is sufficient.

In the settings file, the applePlayerConfiguration section must contain the configuration, like in the following example. Note that the default values of the inner parameters in applePlayerConfiguration can be nil.

      "settings": {
"general": {
"liveBackOff":15000,
}
"applePlayerConfiguration":
{
"preferredMaximumResolutionForExpensiveNetworks":{
"width":30,
"height":20
},
"preferredPeakBitRate":10000,
"canUseNetworkResourcesForLiveStreamingWhilePaused":true,
"preferredForwardBufferDurationAtStart":20000,
"preferredForwardBufferDurationAfterPlay":30000,
"preferredPeakBitRateForExpensiveNetworks":200000,
"startsOnFirstEligibleVariant":true,
"automaticallyWaitsToMinimizeStalling":true
}
}

Here's an enhanced description of each parameter:

automaticallyWaitsToMinimizeStalling:​

  • Performance Impact: By preemptively delaying playback when stalling is predicted, this setting helps avoid interruptions, resulting in smoother playback and reducing mid-play buffering.
  • SPI Reliability: Reducing stalling events improves SPI metrics for buffering frequency and playback smoothness, making these metrics more accurately reflect user experience with fewer disruptions.

canUseNetworkResourcesForLiveStreamingWhilePaused:​

  • Performance Impact: This allows the player to refresh the live stream's state even when paused, keeping playback up-to-date. When playback resumes, it picks up from the most current position without needing a full reload.
  • SPI Reliability: SPI metrics like latency and synchronization with the live stream remain more accurate, as the player resumes with minimal delay and reflects the latest content, ensuring reliable streaming data.

liveBackOff:​

  • Performance Impact: Adding a small delay from the true live position provides a buffer to handle network variability without affecting playback continuity, reducing the chances of rebuffering. Default is 0.
  • SPI Reliability: The buffer allows the player to handle fluctuations in real-time streaming more effectively, leading to more stable SPI metrics for playback continuity, latency, and stalling rates.

preferredForwardBufferDurationAfterPlay:​

  • Performance Impact: By buffering ahead as playback progresses, the player can handle brief network slowdowns or interruptions without stalling, improving playback continuity.
  • SPI Reliability: A steady buffer throughout playback reduces the likelihood of stalls due to network variability, leading to more consistent SPI measurements for buffering frequency and playtime.

preferredForwardBufferDurationAtStart:​

  • Performance Impact: Setting a pre-buffer time before playback starts ensures that a segment of the stream is already loaded, reducing initial buffering and helping playback begin smoothly.
  • SPI Reliability: This initial buffer improves metrics for startup time and initial buffering events, making the SPI indicators more reflective of a smooth start-up experience.

preferredMaximumResolutionForExpensiveNetworks:​

  • Performance Impact: By limiting resolution on cellular or metered networks, this setting minimizes data use and prevents buffering due to insufficient bandwidth, especially on mobile connections.
  • SPI Reliability: Lowering resolution where necessary reduces the likelihood of interruptions and data overuse, leading to better SPI scores for buffering frequency and quality-to-bandwidth ratio.

preferredPeakBitRate:​

  • Performance Impact: Capping the peak bit rate during playback helps stabilize data use, adapting playback quality to network constraints and reducing the risk of stalling on limited connections.
  • SPI Reliability: Controlling bit rate allows the player to maintain smoother playback across various network conditions, supporting consistent SPI metrics for buffering frequency and data efficiency.

preferredPeakBitRateForExpensiveNetworks:​

  • Performance Impact: This setting allows for even more control over data usage on metered networks, capping bit rate to prevent high data costs and buffering.
  • SPI Reliability: Reducing data demands on cellular networks minimizes the likelihood of stalling, creating more accurate SPI metrics that reflect performance in constrained conditions, particularly on mobile devices.

startsOnFirstEligibleVariant:​

  • Performance Impact: By starting playback with the first supported variant (often a lower-quality stream) rather than waiting for a higher-quality stream, this setting can significantly reduce startup time, enhancing the speed of initial playback.
  • SPI Reliability: Faster startup times improve SPI metrics related to initial buffering and startup delay, making them more reflective of a seamless, responsive experience for users.

For more, please refer to the AVfoundation official documentation.