2022-08-28 22:48:49 +05:30
|
|
|
import Defaults
|
2022-06-18 18:09:49 +05:30
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct Buffering: View {
|
|
|
|
var reason = "Buffering stream..."
|
|
|
|
var state: String?
|
|
|
|
|
2022-08-28 22:48:49 +05:30
|
|
|
#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-02 04:35:31 +05:30
|
|
|
player.playingFullScreen ? fullScreenPlayerControlsLayout : regularPlayerControlsLayout
|
2022-08-28 22:48:49 +05:30
|
|
|
}
|
|
|
|
|
2022-06-18 18:09:49 +05:30
|
|
|
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 22:48:49 +05:30
|
|
|
.font(.system(size: playerControlsLayout.timeFontSize))
|
2022-06-18 18:09:49 +05:30
|
|
|
if let state = state {
|
|
|
|
Text(state)
|
2022-08-28 22:48:49 +05:30
|
|
|
.font(.system(size: playerControlsLayout.bufferingStateFontSize).monospacedDigit())
|
2022-06-18 18:09:49 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(8)
|
|
|
|
.modifier(ControlBackgroundModifier())
|
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Buffering_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
Buffering(state: "100% (2.95s)")
|
|
|
|
}
|
|
|
|
}
|