mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Extract playback stats view
This commit is contained in:
@@ -2,7 +2,6 @@ import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct ControlsOverlay: View {
|
||||
@EnvironmentObject<NetworkStateModel> private var networkState
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<PlayerControlsModel> private var model
|
||||
|
||||
@@ -73,7 +72,7 @@ struct ControlsOverlay: View {
|
||||
showMPVPlaybackStats
|
||||
{
|
||||
Section(header: controlsHeader("Statistics")) {
|
||||
mpvPlaybackStats
|
||||
PlaybackStatsView()
|
||||
}
|
||||
#if os(tvOS)
|
||||
.frame(width: 400)
|
||||
@@ -385,30 +384,6 @@ struct ControlsOverlay: View {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
var mpvPlaybackStats: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
mpvPlaybackStatRow("Hardware decoder", player.mpvBackend.hwDecoder)
|
||||
mpvPlaybackStatRow("Dropped frames", String(player.mpvBackend.frameDropCount))
|
||||
mpvPlaybackStatRow("Stream FPS", String(format: "%.2ffps", player.mpvBackend.outputFps))
|
||||
mpvPlaybackStatRow("Cached time", String(format: "%.2fs", player.mpvBackend.cacheDuration))
|
||||
}
|
||||
.padding(.top, 2)
|
||||
#if os(tvOS)
|
||||
.font(.system(size: 20))
|
||||
#else
|
||||
.font(.system(size: 11))
|
||||
#endif
|
||||
}
|
||||
|
||||
func mpvPlaybackStatRow(_ label: String, _ value: String) -> some View {
|
||||
HStack {
|
||||
Text(label)
|
||||
.foregroundColor(.secondary)
|
||||
Spacer()
|
||||
Text(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ControlsOverlay_Previews: PreviewProvider {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct NetworkState: View {
|
||||
@EnvironmentObject<NetworkStateModel> private var model
|
||||
@ObservedObject private var model = NetworkStateModel.shared
|
||||
|
||||
var body: some View {
|
||||
Buffering(state: model.fullStateText)
|
||||
|
37
Shared/Player/Controls/PlaybackStatsView.swift
Normal file
37
Shared/Player/Controls/PlaybackStatsView.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
import SwiftUI
|
||||
|
||||
struct PlaybackStatsView: View {
|
||||
@ObservedObject private var networkState = NetworkStateModel.shared
|
||||
|
||||
private var player: PlayerModel { .shared }
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
mpvPlaybackStatRow("Hardware decoder", player.mpvBackend.hwDecoder)
|
||||
mpvPlaybackStatRow("Dropped frames", String(player.mpvBackend.frameDropCount))
|
||||
mpvPlaybackStatRow("Stream FPS", String(format: "%.2ffps", player.mpvBackend.outputFps))
|
||||
mpvPlaybackStatRow("Cached time", String(format: "%.2fs", player.mpvBackend.cacheDuration))
|
||||
}
|
||||
.padding(.top, 2)
|
||||
#if os(tvOS)
|
||||
.font(.system(size: 20))
|
||||
#else
|
||||
.font(.system(size: 11))
|
||||
#endif
|
||||
}
|
||||
|
||||
func mpvPlaybackStatRow(_ label: String, _ value: String) -> some View {
|
||||
HStack {
|
||||
Text(label)
|
||||
.foregroundColor(.secondary)
|
||||
Spacer()
|
||||
Text(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PlaybackStatsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PlaybackStatsView()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user