mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
fix escape key crashing on macOS
just adds an ignore listener so it doesn't crash, nor do anything
This commit is contained in:
parent
c530619039
commit
c48670fa74
1 changed files with 37 additions and 4 deletions
|
|
@ -19,6 +19,7 @@ class KSPlayerView: UIView {
|
||||||
weak var viewManager: KSPlayerViewManager?
|
weak var viewManager: KSPlayerViewManager?
|
||||||
|
|
||||||
// Event blocks for Fabric
|
// Event blocks for Fabric
|
||||||
|
@objc var onExitFullscreen: RCTDirectEventBlock?
|
||||||
@objc var onLoad: RCTDirectEventBlock?
|
@objc var onLoad: RCTDirectEventBlock?
|
||||||
@objc var onProgress: RCTDirectEventBlock?
|
@objc var onProgress: RCTDirectEventBlock?
|
||||||
@objc var onBuffering: RCTDirectEventBlock?
|
@objc var onBuffering: RCTDirectEventBlock?
|
||||||
|
|
@ -101,6 +102,17 @@ class KSPlayerView: UIView {
|
||||||
setupPlayerView()
|
setupPlayerView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var canBecomeFirstResponder: Bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override func didMoveToWindow() {
|
||||||
|
super.didMoveToWindow()
|
||||||
|
becomeFirstResponder()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private func setupPlayerView() {
|
private func setupPlayerView() {
|
||||||
playerView = IOSVideoPlayerView()
|
playerView = IOSVideoPlayerView()
|
||||||
playerView.translatesAutoresizingMaskIntoConstraints = false
|
playerView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
@ -237,10 +249,10 @@ class KSPlayerView: UIView {
|
||||||
options.registerRemoteControll = false
|
options.registerRemoteControll = false
|
||||||
|
|
||||||
// PERFORMANCE OPTIMIZATION: Buffer durations for smooth high bitrate playback
|
// PERFORMANCE OPTIMIZATION: Buffer durations for smooth high bitrate playback
|
||||||
// preferredForwardBufferDuration = 5.0s: Increased to prevent stalling on network hiccups
|
// preferredForwardBufferDuration = 3.0s: Slightly increased to reduce rebuffering during playback
|
||||||
options.preferredForwardBufferDuration = 5.0
|
options.preferredForwardBufferDuration = 1.0
|
||||||
// maxBufferDuration = 300.0s: Increased to allow 5 minutes of cache ahead
|
// maxBufferDuration = 120.0s: Increased to allow the player to cache more content ahead of time (2 minutes)
|
||||||
options.maxBufferDuration = 300.0
|
options.maxBufferDuration = 120.0
|
||||||
|
|
||||||
// Enable "second open" to relax startup/seek buffering thresholds (already enabled)
|
// Enable "second open" to relax startup/seek buffering thresholds (already enabled)
|
||||||
options.isSecondOpen = true
|
options.isSecondOpen = true
|
||||||
|
|
@ -315,6 +327,22 @@ class KSPlayerView: UIView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var keyCommands: [UIKeyCommand]? {
|
||||||
|
return [
|
||||||
|
UIKeyCommand(
|
||||||
|
input: UIKeyCommand.inputEscape,
|
||||||
|
modifierFlags: [],
|
||||||
|
action: #selector(handleEscapeKey),
|
||||||
|
discoverabilityTitle: "Exit Fullscreen"
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func handleEscapeKey() {
|
||||||
|
print("KSPlayerView: ESC pressed")
|
||||||
|
sendEvent("onExitFullscreen", [:])
|
||||||
|
}
|
||||||
|
|
||||||
func setVolume(_ volume: Float) {
|
func setVolume(_ volume: Float) {
|
||||||
currentVolume = volume
|
currentVolume = volume
|
||||||
playerView.playerLayer?.player.playbackVolume = volume
|
playerView.playerLayer?.player.playbackVolume = volume
|
||||||
|
|
@ -979,3 +1007,8 @@ extension KSPlayerView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension IOSVideoPlayerView {
|
||||||
|
@objc func handleEscapeKey() {
|
||||||
|
self.next?.perform(#selector(handleEscapeKey))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue