From 79cad4bf3744293a11d2bfcc276a74d5daa836e8 Mon Sep 17 00:00:00 2001 From: imbererzin Date: Mon, 8 Jul 2024 11:40:55 +0300 Subject: [PATCH 1/3] =?UTF-8?q?Add=20startsOnFirstEligibleVariant=20as=20t?= =?UTF-8?q?rue=20in=20player=20setting=20(with=20config=20by=20client=20op?= =?UTF-8?q?tion)=20A=20Boolean=20value=20that=20indicates=20whether=20play?= =?UTF-8?q?back=20starts=20with=20the=20first=20eligible=20variant=20that?= =?UTF-8?q?=20appears=20in=20the=20stream=E2=80=99s=20main=20playlist.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AVPlayerEngine/AVPlayerEngine+AssetLoading.swift | 6 +++++- Classes/Player/PKPlayerSettings.swift | 9 +++++++++ Classes/Player/PlayerWrapper/AVPlayerWrapper.swift | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Classes/Player/AVPlayerEngine/AVPlayerEngine+AssetLoading.swift b/Classes/Player/AVPlayerEngine/AVPlayerEngine+AssetLoading.swift index df58e120..47e92aa5 100644 --- a/Classes/Player/AVPlayerEngine/AVPlayerEngine+AssetLoading.swift +++ b/Classes/Player/AVPlayerEngine/AVPlayerEngine+AssetLoading.swift @@ -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() diff --git a/Classes/Player/PKPlayerSettings.swift b/Classes/Player/PKPlayerSettings.swift index 6ce069a6..7fe522af 100644 --- a/Classes/Player/PKPlayerSettings.swift +++ b/Classes/Player/PKPlayerSettings.swift @@ -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 = true { + 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. @@ -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 @@ -162,6 +170,7 @@ enum PlayerSettingsType { case configuredTimeOffsetFromLive(CMTime) case preventsDisplaySleepDuringVideoPlayback(Bool) case allowAudioFromVideoAssetInBackground(Bool) + case startsOnFirstEligibleVariant (Bool) } /************************************************************/ diff --git a/Classes/Player/PlayerWrapper/AVPlayerWrapper.swift b/Classes/Player/PlayerWrapper/AVPlayerWrapper.swift index 059a2fbf..30bd08cc 100644 --- a/Classes/Player/PlayerWrapper/AVPlayerWrapper.swift +++ b/Classes/Player/PlayerWrapper/AVPlayerWrapper.swift @@ -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 + } + } } } From 8c27c781e68445af2341c2a94ec7d6250145d68b Mon Sep 17 00:00:00 2001 From: Israel Berezin Date: Tue, 9 Jul 2024 12:37:54 +0300 Subject: [PATCH 2/3] fix player notification names (#481) update version to 3.30.2 --- .../AVPlayerEngine+Observation.swift | 20 +++++++++---------- PlayKit.podspec | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Classes/Player/AVPlayerEngine/AVPlayerEngine+Observation.swift b/Classes/Player/AVPlayerEngine/AVPlayerEngine+Observation.swift index 31574c45..2d26d625 100644 --- a/Classes/Player/AVPlayerEngine/AVPlayerEngine+Observation.swift +++ b/Classes/Player/AVPlayerEngine/AVPlayerEngine+Observation.swift @@ -1,7 +1,7 @@ // =================================================================================================== // Copyright (C) 2017 Kaltura Inc. // -// Licensed under the AGPLv3 license, unless a different license for a +// Licensed under the AGPLv3 license, unless a different license for a // particular library is specified in the applicable library path. // // You may obtain a copy of the License at @@ -40,11 +40,11 @@ extension AVPlayerEngine { addObserver(self, forKeyPath: keyPath, options: [.new, .initial], context: &AVPlayerEngine.observerContext) } - NotificationCenter.default.addObserver(self, selector: #selector(self.didFailToPlayToEndTime(_:)), name: .AVPlayerItemFailedToPlayToEndTime, object: self.currentItem) - NotificationCenter.default.addObserver(self, selector: #selector(self.didPlayToEndTime(_:)), name: .AVPlayerItemDidPlayToEndTime, object: self.currentItem) - NotificationCenter.default.addObserver(self, selector: #selector(self.onAccessLogEntryNotification), name: .AVPlayerItemNewAccessLogEntry, object: self.currentItem) - NotificationCenter.default.addObserver(self, selector: #selector(self.onErrorLogEntryNotification), name: AVPlayerItem.newAccessLogEntryNotification, object: self.currentItem) - NotificationCenter.default.addObserver(self, selector: #selector(self.onPlaybackStalledNotification), name: .AVPlayerItemPlaybackStalled, object: self.currentItem) + NotificationCenter.default.addObserver(self, selector: #selector(self.didFailToPlayToEndTime(_:)), name: AVPlayerItem.failedToPlayToEndTimeNotification, object: self.currentItem) + NotificationCenter.default.addObserver(self, selector: #selector(self.didPlayToEndTime(_:)), name: AVPlayerItem.didPlayToEndTimeNotification, object: self.currentItem) + NotificationCenter.default.addObserver(self, selector: #selector(self.onAccessLogEntryNotification), name: AVPlayerItem.newAccessLogEntryNotification, object: self.currentItem) + NotificationCenter.default.addObserver(self, selector: #selector(self.onErrorLogEntryNotification), name: AVPlayerItem.newErrorLogEntryNotification, object: self.currentItem) + NotificationCenter.default.addObserver(self, selector: #selector(self.onPlaybackStalledNotification), name: AVPlayerItem.playbackStalledNotification, object: self.currentItem) NotificationCenter.default.addObserver(self, selector: #selector(self.timebaseChanged), name: Notification.Name(kCMTimebaseNotification_EffectiveRateChanged as String), object: nil) } @@ -60,11 +60,11 @@ extension AVPlayerEngine { removeObserver(self, forKeyPath: keyPath, context: &AVPlayerEngine.observerContext) } - NotificationCenter.default.removeObserver(self, name: .AVPlayerItemFailedToPlayToEndTime, object: self.currentItem) - NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: self.currentItem) + NotificationCenter.default.removeObserver(self, name: AVPlayerItem.failedToPlayToEndTimeNotification, object: self.currentItem) + NotificationCenter.default.removeObserver(self, name: AVPlayerItem.didPlayToEndTimeNotification, object: self.currentItem) NotificationCenter.default.removeObserver(self, name: AVPlayerItem.newAccessLogEntryNotification, object: self.currentItem) - NotificationCenter.default.removeObserver(self, name: .AVPlayerItemNewErrorLogEntry, object: self.currentItem) - NotificationCenter.default.removeObserver(self, name: .AVPlayerItemPlaybackStalled, object: self.currentItem) + NotificationCenter.default.removeObserver(self, name: AVPlayerItem.newErrorLogEntryNotification, object: self.currentItem) + NotificationCenter.default.removeObserver(self, name: AVPlayerItem.playbackStalledNotification, object: self.currentItem) NotificationCenter.default.removeObserver(self, name: Notification.Name(kCMTimebaseNotification_EffectiveRateChanged as String), object: nil) } diff --git a/PlayKit.podspec b/PlayKit.podspec index 365e06ce..31e1e455 100644 --- a/PlayKit.podspec +++ b/PlayKit.podspec @@ -4,7 +4,7 @@ suffix = '.0000' # Dev mode Pod::Spec.new do |s| s.name = 'PlayKit' -s.version = '3.30.1' + suffix +s.version = '3.30.2' + suffix s.summary = 'PlayKit: Kaltura Mobile Player SDK - iOS' s.homepage = 'https://github.com/kaltura/playkit-ios' s.license = { :type => 'AGPLv3', :text => 'AGPLv3' } From 3d0061aec1dafbb8afad536f6f88c9a4bb2656a0 Mon Sep 17 00:00:00 2001 From: imbererzin Date: Sun, 14 Jul 2024 11:11:00 +0300 Subject: [PATCH 3/3] update startsOnFirstEligibleVariant default to false --- Classes/Player/PKPlayerSettings.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Player/PKPlayerSettings.swift b/Classes/Player/PKPlayerSettings.swift index 7fe522af..b7be4113 100644 --- a/Classes/Player/PKPlayerSettings.swift +++ b/Classes/Player/PKPlayerSettings.swift @@ -67,7 +67,7 @@ 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 = true { + @objc public var startsOnFirstEligibleVariant: Bool = false { didSet { self.onChange?(.startsOnFirstEligibleVariant(startsOnFirstEligibleVariant)) }