2022-06-18 12:39:49 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct OpeningStream: View {
|
2022-11-24 20:36:05 +00:00
|
|
|
@ObservedObject private var player = PlayerModel.shared
|
|
|
|
@ObservedObject private var model = NetworkStateModel.shared
|
2022-06-18 12:39:49 +00:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Buffering(reason: reason, state: state)
|
|
|
|
.opacity(visible ? 1 : 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
var visible: Bool {
|
|
|
|
(!player.currentItem.isNil && !player.videoBeingOpened.isNil) || (player.isLoadingVideo && !model.pausedForCache && !player.isSeeking)
|
|
|
|
}
|
|
|
|
|
|
|
|
var reason: String {
|
2022-09-27 13:22:40 +00:00
|
|
|
guard player.videoBeingOpened == nil else {
|
2022-09-04 15:28:30 +00:00
|
|
|
return "Loading streams...".localized()
|
|
|
|
}
|
|
|
|
|
|
|
|
if player.musicMode {
|
|
|
|
return "Opening audio stream...".localized()
|
|
|
|
}
|
|
|
|
|
2022-11-11 17:57:46 +00:00
|
|
|
if let selection = player.streamSelection {
|
|
|
|
if selection.isLocal {
|
|
|
|
return "Opening file..."
|
|
|
|
} else {
|
|
|
|
return String(format: "Opening %@ stream...".localized(), selection.shortQuality)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-11 20:38:20 +00:00
|
|
|
return "Loading streams...".localized()
|
2022-06-18 12:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var state: String? {
|
|
|
|
player.videoBeingOpened.isNil ? model.bufferingStateText : nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct OpeningStream_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
OpeningStream()
|
|
|
|
.injectFixtureEnvironmentObjects()
|
|
|
|
}
|
|
|
|
}
|