import SwiftUI import TVAnarchyCore /// Stream buffer controls for a device with the stream service enabled. struct StreamPolicySection: View { @Binding var policy: StreamPolicy /// When set, caps the buffer slider at half this episode length. var episodeDuration: Double? private var maxBuffer: Int { policy.sliderMax(episodeDuration: episodeDuration) } private var effective: Int { policy.effectiveBufferSeconds(episodeDuration: episodeDuration) } var body: some View { VStack(alignment: .leading, spacing: 8) { Text("Stream buffer").font(.headline) Stepper("Buffer: \(policy.bufferSeconds)s (effective \(effective)s)", value: $policy.bufferSeconds, in: 15...maxBuffer, step: 15) .fixedSize() .help("Seconds of playback to hold ahead when streaming from the storage server") Text("Required buffer is capped at half the episode length (\(maxBuffer)s max right now). Higher values absorb jitter on slow links but delay start-of-play.") .font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true) } } }