2022-08-28 17:18:49 +00:00
|
|
|
import Defaults
|
2022-06-18 12:39:49 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct Buffering: View {
|
2022-09-04 15:28:30 +00:00
|
|
|
var reason = "Buffering stream...".localized()
|
2022-06-18 12:39:49 +00:00
|
|
|
var state: String?
|
|
|
|
|
2022-08-28 17:18:49 +00:00
|
|
|
#if os(iOS)
|
|
|
|
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
|
|
|
|
|
|
|
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
|
|
|
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
|
|
|
|
|
|
|
var playerControlsLayout: PlayerControlsLayout {
|
2022-09-01 23:05:31 +00:00
|
|
|
player.playingFullScreen ? fullScreenPlayerControlsLayout : regularPlayerControlsLayout
|
2022-08-28 17:18:49 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 12:39:49 +00:00
|
|
|
var body: some View {
|
|
|
|
VStack(spacing: 2) {
|
|
|
|
ProgressView()
|
|
|
|
#if os(macOS)
|
|
|
|
.scaleEffect(0.4)
|
|
|
|
#else
|
|
|
|
.scaleEffect(0.7)
|
|
|
|
#endif
|
|
|
|
.frame(maxHeight: 14)
|
|
|
|
.progressViewStyle(.circular)
|
|
|
|
|
|
|
|
Text(reason)
|
2022-08-28 17:18:49 +00:00
|
|
|
.font(.system(size: playerControlsLayout.timeFontSize))
|
2022-09-28 14:27:01 +00:00
|
|
|
if let state {
|
2022-06-18 12:39:49 +00:00
|
|
|
Text(state)
|
2022-08-28 17:18:49 +00:00
|
|
|
.font(.system(size: playerControlsLayout.bufferingStateFontSize).monospacedDigit())
|
2022-06-18 12:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(8)
|
|
|
|
.modifier(ControlBackgroundModifier())
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Buffering_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
Buffering(state: "100% (2.95s)")
|
|
|
|
}
|
|
|
|
}
|