mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 18:24:02 +00:00
Player controls UI changes
WIP on controls Chapters working Add previews variable Add lists ids WIP
This commit is contained in:
37
Shared/Player/Controls/OSD/Buffering.swift
Normal file
37
Shared/Player/Controls/OSD/Buffering.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct Buffering: View {
|
||||
var reason = "Buffering stream..."
|
||||
var state: String?
|
||||
|
||||
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)
|
||||
.font(.caption)
|
||||
if let state = state {
|
||||
Text(state)
|
||||
.font(.caption2.monospacedDigit())
|
||||
}
|
||||
}
|
||||
.padding(8)
|
||||
.modifier(ControlBackgroundModifier())
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
struct Buffering_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Buffering(state: "100% (2.95s)")
|
||||
}
|
||||
}
|
22
Shared/Player/Controls/OSD/NetworkState.swift
Normal file
22
Shared/Player/Controls/OSD/NetworkState.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import SwiftUI
|
||||
|
||||
struct NetworkState: View {
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<NetworkStateModel> private var model
|
||||
|
||||
var body: some View {
|
||||
Buffering(state: model.fullStateText)
|
||||
.opacity(model.pausedForCache || player.isSeeking ? 1 : 0)
|
||||
}
|
||||
}
|
||||
|
||||
struct NetworkState_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let networkState = NetworkStateModel()
|
||||
networkState.bufferingState = 30
|
||||
|
||||
return NetworkState()
|
||||
.environmentObject(networkState)
|
||||
.environmentObject(PlayerModel())
|
||||
}
|
||||
}
|
37
Shared/Player/Controls/OSD/OpeningStream.swift
Normal file
37
Shared/Player/Controls/OSD/OpeningStream.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
import SwiftUI
|
||||
|
||||
struct OpeningStream: View {
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<NetworkStateModel> private var model
|
||||
|
||||
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 {
|
||||
player.videoBeingOpened.isNil ? "Opening\(streamQuality)stream..." : "Loading streams..."
|
||||
}
|
||||
|
||||
var state: String? {
|
||||
player.videoBeingOpened.isNil ? model.bufferingStateText : nil
|
||||
}
|
||||
|
||||
var streamQuality: String {
|
||||
guard let stream = player.streamSelection else { return " " }
|
||||
guard !player.musicMode else { return " audio " }
|
||||
|
||||
return " \(stream.shortQuality) "
|
||||
}
|
||||
}
|
||||
|
||||
struct OpeningStream_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
OpeningStream()
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user