Skip to content

Commit

Permalink
Merge branch 'fix_error_notifcation_name' of https://github.com/kaltu…
Browse files Browse the repository at this point in the history
…ra/playkit-ios into fix_error_notifcation_name

* 'fix_error_notifcation_name' of https://github.com/kaltura/playkit-ios:
  update startsOnFirstEligibleVariant default to false
  fix player notification names (#481)
  Add startsOnFirstEligibleVariant as true in player setting (with config by client option) A Boolean value that indicates whether playback starts with the first eligible variant that appears in the stream’s main playlist.
  • Loading branch information
imberezin committed Sep 30, 2024
2 parents abbc494 + 4fda43c commit 258c67b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ extension AVPlayerEngine {
if #available(iOS 11.0, tvOS 11.0, *) {
playerItem.preferredMaximumResolution = newAsset.playerSettings.network.preferredMaximumResolution
}


if #available(iOS 14.0, tvOS 14.0, *) {
playerItem.startsOnFirstEligibleVariant = newAsset.playerSettings.network.startsOnFirstEligibleVariant
}

// Add observers
self.removeObservers()
self.addObservers()
Expand Down
9 changes: 9 additions & 0 deletions Classes/Player/PKPlayerSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ typealias SettingsChange = ((PlayerSettingsType) -> Void)
}
}

/// A Boolean value that indicates whether playback starts with the first eligible variant that appears in the stream’s main playlist.
/// For further details please see Apple's documentation: https://developer.apple.com/documentation/avfoundation/avplayeritem/3579514-startsonfirsteligiblevariant?language=objc
@objc public var startsOnFirstEligibleVariant: Bool = false {
didSet {
self.onChange?(.startsOnFirstEligibleVariant(startsOnFirstEligibleVariant))
}
}
/// Tells the player whether or not to buffer the media, or stop after initializing the asset and fetching the keys.
///
/// Default value is true, initialize the asset, fetch the keys and buffer the media.
Expand All @@ -79,6 +86,7 @@ typealias SettingsChange = ((PlayerSettingsType) -> Void)
copy.preferredPeakBitRate = self.preferredPeakBitRate
copy.preferredMaximumResolution = self.preferredMaximumResolution
copy.preferredForwardBufferDuration = self.preferredForwardBufferDuration
copy.startsOnFirstEligibleVariant = self.startsOnFirstEligibleVariant
copy.automaticallyWaitsToMinimizeStalling = self.automaticallyWaitsToMinimizeStalling

return copy
Expand Down Expand Up @@ -162,6 +170,7 @@ enum PlayerSettingsType {
case configuredTimeOffsetFromLive(CMTime)
case preventsDisplaySleepDuringVideoPlayback(Bool)
case allowAudioFromVideoAssetInBackground(Bool)
case startsOnFirstEligibleVariant (Bool)
}

/************************************************************/
Expand Down
5 changes: 5 additions & 0 deletions Classes/Player/PlayerWrapper/AVPlayerWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ open class AVPlayerWrapper: NSObject, PlayerEngine {
}
case .allowAudioFromVideoAssetInBackground(let allowAudioFromVideoAssetInBackground):
self.currentPlayer.allowAudioFromVideoAssetInBackground = allowAudioFromVideoAssetInBackground
case .startsOnFirstEligibleVariant(let startsOnFirstEligibleVariant):
if #available(iOS 14.0, tvOS 14.0, *) {
self.currentPlayer.currentItem?.startsOnFirstEligibleVariant = startsOnFirstEligibleVariant
}

}
}
}
Expand Down

0 comments on commit 258c67b

Please sign in to comment.