From 5c8ab7232775a814985e6a1d9b614cc4d5e588ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaume=20Cornado=CC=81?= Date: Tue, 10 Feb 2026 23:15:02 +0100 Subject: [PATCH] Add skipInitialTimeSet to prevent seeking on live streams setConfigurationValues unconditionally sets player.time to startTime (default 0) the first time playback ticks advance. For VOD content this is correct, but for live HLS streams with timeshift buffers it causes VLC to seek away from the live edge, triggering a long rebuffer (observed 3+ minutes) or playback starting hours behind real-time. Adding a `skipInitialTimeSet` flag on Configuration lets callers opt out of the initial time assignment. When set to `true`, VLC keeps the position it naturally chose (the live edge), and the rest of setConfigurationValues (rate, subtitles, audio, aspect fill) still applies normally. Co-Authored-By: Claude Opus 4.6 --- Sources/VLCUI/UIVLCVideoPlayerView.swift | 4 +++- Sources/VLCUI/VLCVideoPlayer/Configuration.swift | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/VLCUI/UIVLCVideoPlayerView.swift b/Sources/VLCUI/UIVLCVideoPlayerView.swift index f446ad1..2a8618a 100644 --- a/Sources/VLCUI/UIVLCVideoPlayerView.swift +++ b/Sources/VLCUI/UIVLCVideoPlayerView.swift @@ -233,7 +233,9 @@ extension UIVLCVideoPlayerView: VLCMediaPlayerDelegate { private func setConfigurationValues(with player: VLCMediaPlayer, from configuration: VLCVideoPlayer.Configuration) { - player.time = VLCTime(int: configuration.startTime.asTicks.asInt32) + if !configuration.skipInitialTimeSet { + player.time = VLCTime(int: configuration.startTime.asTicks.asInt32) + } let defaultPlayerSpeed = player.rate(from: configuration.rate) player.fastForward(atRate: defaultPlayerSpeed) diff --git a/Sources/VLCUI/VLCVideoPlayer/Configuration.swift b/Sources/VLCUI/VLCVideoPlayer/Configuration.swift index fa64bf7..5ade3ac 100644 --- a/Sources/VLCUI/VLCVideoPlayer/Configuration.swift +++ b/Sources/VLCUI/VLCVideoPlayer/Configuration.swift @@ -23,6 +23,14 @@ public extension VLCVideoPlayer { public var subtitleColor: ValueSelector<_PlatformColor> = .auto public var playbackChildren: [PlaybackChild] = [] public var options: [String: Any] = [:] + /// When `true`, the initial `player.time` assignment in + /// `setConfigurationValues` is skipped. + /// + /// Use this for live streams where an explicit seek — even to the + /// current position — causes VLC to flush its buffers and re-acquire + /// the stream, resulting in long rebuffering delays or loss of the + /// live-edge position. + public var skipInitialTimeSet: Bool = false public init(url: URL) { self.url = url