1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 22:30:32 +05:30
yattee/Shared/Player/Controls/OSD/OpeningStream.swift

46 lines
1.3 KiB
Swift
Raw Normal View History

import SwiftUI
struct OpeningStream: View {
@ObservedObject private var player = PlayerModel.shared
@ObservedObject private var model = NetworkStateModel.shared
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 18:52:40 +05:30
guard player.videoBeingOpened == nil else {
2022-09-04 20:58:30 +05:30
return "Loading streams...".localized()
}
if player.musicMode {
return "Opening audio stream...".localized()
}
2022-11-11 23:27:46 +05:30
if let selection = player.streamSelection {
if selection.isLocal {
2023-05-20 19:29:47 +05:30
return "Opening file...".localized()
2022-11-11 23:27:46 +05:30
}
2023-06-17 17:39:51 +05:30
return String(format: "Opening %@ stream...".localized(), selection.shortQuality)
2022-11-11 23:27:46 +05:30
}
2022-11-12 02:08:20 +05:30
return "Loading streams...".localized()
}
var state: String? {
player.videoBeingOpened.isNil ? model.bufferingStateText : nil
}
}
struct OpeningStream_Previews: PreviewProvider {
static var previews: some View {
OpeningStream()
.injectFixtureEnvironmentObjects()
}
}