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 {
|
2022-09-04 20:58:30 +05:30
|
|
|
var reason = "Buffering stream...".localized()
|
2022-06-18 18:09:49 +05:30
|
|
|
var state: String?
|
|
|
|
|
2022-11-25 02:06:05 +05:30
|
|
|
@ObservedObject private var player = PlayerModel.shared
|
2022-08-28 22:48:49 +05:30
|
|
|
|
|
|
|
@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-09-28 19:57:01 +05:30
|
|
|
if let state {
|
2022-06-18 18:09:49 +05:30
|
|
|
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)")
|
|
|
|
}
|
|
|
|
}
|