-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from kinescope/hotfix/overlay-independent-retry
Fix live-translation in looped strategy with partially disabled UI
- Loading branch information
Showing
17 changed files
with
218 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Sources/KinescopeSDK/Player/Observers/CurrentItemObserver.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// CurrentItemObserver.swift | ||
// KinescopeSDK | ||
// | ||
// Created by Nikita Korobeinikov on 16.06.2024. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
final class CurrentItemObserver: KVOObserverFactory { | ||
|
||
private weak var playerBody: KinescopePlayerBody? | ||
|
||
private var currentItemChanged: (AVPlayerItem?) -> Void | ||
|
||
init(playerBody: KinescopePlayerBody, | ||
currentItemChanged: @escaping (AVPlayerItem?) -> Void) { | ||
self.playerBody = playerBody | ||
self.currentItemChanged = currentItemChanged | ||
} | ||
|
||
func provide() -> NSKeyValueObservation? { | ||
playerBody?.strategy.player.observe( | ||
\.currentItem, | ||
options: [.new, .old], | ||
changeHandler: { [weak self] item, _ in | ||
self?.currentItemChanged(item.currentItem) | ||
|
||
Kinescope.shared.logger?.log( | ||
message: "AVPlayer.CurrentItem – \(item.currentItem.debugDescription)", | ||
level: KinescopeLoggerLevel.player | ||
) | ||
} | ||
) | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
Sources/KinescopeSDK/Player/Observers/EmptyBufferObserver.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// EmptyBufferObserver.swift | ||
// KinescopeSDK | ||
// | ||
// Created by Nikita Korobeinikov on 24.06.2024. | ||
// | ||
|
||
import Foundation | ||
import AVFoundation | ||
|
||
final class EmptyBufferObserver: KVOObserverFactory { | ||
|
||
private weak var playerBody: KinescopePlayerBody? | ||
private weak var repeater: Repeater? | ||
|
||
init(playerBody: KinescopePlayerBody, | ||
repeater: Repeater) { | ||
self.repeater = repeater | ||
self.playerBody = playerBody | ||
} | ||
|
||
func provide() -> NSKeyValueObservation? { | ||
playerBody?.strategy.player.currentItem?.observe( | ||
\.isPlaybackBufferEmpty, | ||
options: [.new, .old], | ||
changeHandler: { [weak self] item, value in | ||
let isBufferEmpty = value.newValue ?? item.isPlaybackBufferEmpty | ||
if isBufferEmpty { | ||
self?.repeater?.start() | ||
} | ||
|
||
Kinescope.shared.logger?.log( | ||
message: "AVPlayer.isPlaybackBufferEmpty – \(isBufferEmpty)", | ||
level: KinescopeLoggerLevel.player | ||
) | ||
} | ||
) | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.