2022-06-18 12:39:49 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct NetworkState: View {
|
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
|
|
|
@EnvironmentObject<NetworkStateModel> private var model
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Buffering(state: model.fullStateText)
|
2022-06-24 23:39:29 +00:00
|
|
|
.opacity(visible ? 1 : 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
var visible: Bool {
|
2022-08-06 14:28:19 +00:00
|
|
|
player.isPlaying && ((player.activeBackend == .mpv && model.pausedForCache) || player.isSeeking)
|
2022-06-18 12:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct NetworkState_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
let networkState = NetworkStateModel()
|
|
|
|
networkState.bufferingState = 30
|
|
|
|
|
|
|
|
return NetworkState()
|
|
|
|
.environmentObject(networkState)
|
|
|
|
.environmentObject(PlayerModel())
|
|
|
|
}
|
|
|
|
}
|