mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 18:24:02 +00:00
Improve performance and add statistics for MPV
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import Defaults
|
||||
import Foundation
|
||||
import SDWebImageSwiftUI
|
||||
import SwiftUI
|
||||
@@ -22,6 +23,8 @@ struct PlayerControls: View {
|
||||
@FocusState private var focusedField: Field?
|
||||
#endif
|
||||
|
||||
@Default(.showMPVPlaybackStats) private var showMPVPlaybackStats
|
||||
|
||||
init(player: PlayerModel, thumbnails: ThumbnailsModel) {
|
||||
self.player = player
|
||||
self.thumbnails = thumbnails
|
||||
@@ -49,6 +52,10 @@ struct PlayerControls: View {
|
||||
Spacer()
|
||||
|
||||
Group {
|
||||
if player.activeBackend == .mpv, showMPVPlaybackStats {
|
||||
mpvPlaybackStats
|
||||
}
|
||||
|
||||
timeline
|
||||
.offset(y: 10)
|
||||
.zIndex(1)
|
||||
@@ -103,6 +110,30 @@ struct PlayerControls: View {
|
||||
}
|
||||
}
|
||||
|
||||
var mpvPlaybackStats: some View {
|
||||
HStack {
|
||||
Group {
|
||||
Text("hw decoder: \(player.mpvBackend.hwDecoder)")
|
||||
Text("dropped: \(player.mpvBackend.frameDropCount)")
|
||||
Text("output fps: \(player.mpvBackend.outputFps)")
|
||||
}
|
||||
.padding(4)
|
||||
#if os(macOS)
|
||||
.background(VisualEffectBlur(material: .hudWindow))
|
||||
#elseif os(iOS)
|
||||
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
|
||||
#else
|
||||
.background(.thinMaterial)
|
||||
#endif
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
|
||||
Spacer()
|
||||
}
|
||||
#if !os(tvOS)
|
||||
.font(.system(size: 9))
|
||||
#endif
|
||||
}
|
||||
|
||||
var timeline: some View {
|
||||
TimelineView(duration: durationBinding, current: currentTimeBinding, cornerRadius: 0)
|
||||
}
|
||||
@@ -164,14 +195,11 @@ struct PlayerControls: View {
|
||||
var buttonsBar: some View {
|
||||
HStack {
|
||||
#if !os(tvOS)
|
||||
#if os(iOS)
|
||||
hidePlayerButton
|
||||
#endif
|
||||
|
||||
fullscreenButton
|
||||
|
||||
#if os(iOS)
|
||||
pipButton
|
||||
.padding(.leading, 5)
|
||||
#endif
|
||||
|
||||
Spacer()
|
||||
@@ -257,8 +285,7 @@ struct PlayerControls: View {
|
||||
}
|
||||
|
||||
private var backendButton: some View {
|
||||
let label = "\(player.activeBackend.label)\(player.activeBackend == .mpv ? " - \(player.mpvBackend.frameDropCount)" : "")"
|
||||
return button(label, width: 120) {
|
||||
button(player.activeBackend.label, width: 100) {
|
||||
player.saveTime {
|
||||
player.changeActiveBackend(from: player.activeBackend, to: player.activeBackend.next())
|
||||
model.resetTimer()
|
||||
|
Reference in New Issue
Block a user