From c48670fa7487fc698f7d84966d9523f4c4ababe5 Mon Sep 17 00:00:00 2001 From: Eazvy <57739965+Eazvy@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:13:04 -0500 Subject: [PATCH 1/2] fix escape key crashing on macOS just adds an ignore listener so it doesn't crash, nor do anything --- ios/KSPlayerView.swift | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/ios/KSPlayerView.swift b/ios/KSPlayerView.swift index 818aae7..91a8f21 100644 --- a/ios/KSPlayerView.swift +++ b/ios/KSPlayerView.swift @@ -19,6 +19,7 @@ class KSPlayerView: UIView { weak var viewManager: KSPlayerViewManager? // Event blocks for Fabric + @objc var onExitFullscreen: RCTDirectEventBlock? @objc var onLoad: RCTDirectEventBlock? @objc var onProgress: RCTDirectEventBlock? @objc var onBuffering: RCTDirectEventBlock? @@ -101,6 +102,17 @@ class KSPlayerView: UIView { setupPlayerView() } + override var canBecomeFirstResponder: Bool { + return true + } + + override func didMoveToWindow() { + super.didMoveToWindow() + becomeFirstResponder() + } + + + private func setupPlayerView() { playerView = IOSVideoPlayerView() playerView.translatesAutoresizingMaskIntoConstraints = false @@ -237,10 +249,10 @@ class KSPlayerView: UIView { options.registerRemoteControll = false // PERFORMANCE OPTIMIZATION: Buffer durations for smooth high bitrate playback - // preferredForwardBufferDuration = 5.0s: Increased to prevent stalling on network hiccups - options.preferredForwardBufferDuration = 5.0 - // maxBufferDuration = 300.0s: Increased to allow 5 minutes of cache ahead - options.maxBufferDuration = 300.0 + // preferredForwardBufferDuration = 3.0s: Slightly increased to reduce rebuffering during playback + options.preferredForwardBufferDuration = 1.0 + // maxBufferDuration = 120.0s: Increased to allow the player to cache more content ahead of time (2 minutes) + options.maxBufferDuration = 120.0 // Enable "second open" to relax startup/seek buffering thresholds (already enabled) 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) { currentVolume = volume playerView.playerLayer?.player.playbackVolume = volume @@ -979,3 +1007,8 @@ extension KSPlayerView { } } +extension IOSVideoPlayerView { + @objc func handleEscapeKey() { + self.next?.perform(#selector(handleEscapeKey)) + } +} From 0f9f6bbe5d2aa1c7771b002e0ae0d3cfa4721a33 Mon Sep 17 00:00:00 2001 From: Eazvy <57739965+Eazvy@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:23:01 -0500 Subject: [PATCH 2/2] fix accidental override of buffering --- ios/KSPlayerView.swift | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/ios/KSPlayerView.swift b/ios/KSPlayerView.swift index 91a8f21..9b8cd45 100644 --- a/ios/KSPlayerView.swift +++ b/ios/KSPlayerView.swift @@ -19,13 +19,13 @@ class KSPlayerView: UIView { weak var viewManager: KSPlayerViewManager? // Event blocks for Fabric - @objc var onExitFullscreen: RCTDirectEventBlock? @objc var onLoad: RCTDirectEventBlock? @objc var onProgress: RCTDirectEventBlock? @objc var onBuffering: RCTDirectEventBlock? @objc var onEnd: RCTDirectEventBlock? @objc var onError: RCTDirectEventBlock? @objc var onBufferingProgress: RCTDirectEventBlock? + @objc var onExitFullscreen: RCTDirectEventBlock? // Property setters that React Native will call @objc var source: NSDictionary? { @@ -102,17 +102,6 @@ class KSPlayerView: UIView { setupPlayerView() } - override var canBecomeFirstResponder: Bool { - return true - } - - override func didMoveToWindow() { - super.didMoveToWindow() - becomeFirstResponder() - } - - - private func setupPlayerView() { playerView = IOSVideoPlayerView() playerView.translatesAutoresizingMaskIntoConstraints = false @@ -249,10 +238,10 @@ class KSPlayerView: UIView { options.registerRemoteControll = false // PERFORMANCE OPTIMIZATION: Buffer durations for smooth high bitrate playback - // preferredForwardBufferDuration = 3.0s: Slightly increased to reduce rebuffering during playback - options.preferredForwardBufferDuration = 1.0 - // maxBufferDuration = 120.0s: Increased to allow the player to cache more content ahead of time (2 minutes) - options.maxBufferDuration = 120.0 + // preferredForwardBufferDuration = 5.0s: Increased to prevent stalling on network hiccups + options.preferredForwardBufferDuration = 5.0 + // maxBufferDuration = 300.0s: Increased to allow 5 minutes of cache ahead + options.maxBufferDuration = 300.0 // Enable "second open" to relax startup/seek buffering thresholds (already enabled) options.isSecondOpen = true @@ -325,7 +314,7 @@ class KSPlayerView: UIView { } else { playerView.play() } - } + } override var keyCommands: [UIKeyCommand]? { return [