mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
More controls improvements
This commit is contained in:
parent
e3cf77e928
commit
3d015f2298
@ -43,7 +43,7 @@ final class PlayerControlsModel: ObservableObject {
|
||||
func handlePresentationChange() {
|
||||
if presentingControls {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.player.backend.startControlsUpdates()
|
||||
self?.player?.backend.startControlsUpdates()
|
||||
self?.resetTimer()
|
||||
}
|
||||
} else {
|
||||
|
@ -58,14 +58,17 @@ struct PlayerControls: View {
|
||||
.offset(y: 10)
|
||||
.zIndex(1)
|
||||
|
||||
bottomBar
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
#if os(macOS)
|
||||
.background(VisualEffectBlur(material: .hudWindow))
|
||||
#elseif os(iOS)
|
||||
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
|
||||
#endif
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
bottomBar
|
||||
#if os(macOS)
|
||||
.background(VisualEffectBlur(material: .hudWindow))
|
||||
#elseif os(iOS)
|
||||
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
|
||||
#endif
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
@ -171,7 +174,9 @@ struct PlayerControls: View {
|
||||
var buttonsBar: some View {
|
||||
HStack(spacing: 20) {
|
||||
#if !os(tvOS)
|
||||
hidePlayerButton
|
||||
#if os(iOS)
|
||||
hidePlayerButton
|
||||
#endif
|
||||
|
||||
fullscreenButton
|
||||
#if os(iOS)
|
||||
@ -235,7 +240,11 @@ struct PlayerControls: View {
|
||||
player.hide()
|
||||
player.closePiP()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
var delay = 0.3
|
||||
#if os(macOS)
|
||||
delay = 0.0
|
||||
#endif
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
|
||||
player.closeCurrentItem()
|
||||
}
|
||||
}
|
||||
@ -260,7 +269,9 @@ struct PlayerControls: View {
|
||||
player.avPlayerBackend.switchToMPVOnPipClose = true
|
||||
}
|
||||
|
||||
player.exitFullScreen()
|
||||
#if !os(macOS)
|
||||
player.exitFullScreen()
|
||||
#endif
|
||||
|
||||
if player.activeBackend != PlayerBackendType.appleAVPlayer {
|
||||
player.saveTime {
|
||||
@ -329,8 +340,6 @@ struct PlayerControls: View {
|
||||
|
||||
var bottomBar: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
Text(model.playbackTime)
|
||||
}
|
||||
.font(.system(size: 15))
|
||||
@ -384,7 +393,7 @@ struct PlayerControls_Previews: PreviewProvider {
|
||||
model.duration = .secondsInDefaultTimescale(120)
|
||||
|
||||
let view = ZStack {
|
||||
Color.red
|
||||
Color.gray
|
||||
|
||||
PlayerControls(player: PlayerModel())
|
||||
.injectFixtureEnvironmentObjects()
|
||||
@ -392,7 +401,7 @@ struct PlayerControls_Previews: PreviewProvider {
|
||||
}
|
||||
|
||||
return Group {
|
||||
if #available(iOS 15.0, *) {
|
||||
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
|
||||
view.previewInterfaceOrientation(.landscapeLeft)
|
||||
} else {
|
||||
view
|
||||
|
@ -38,7 +38,6 @@ struct TimelineView: View {
|
||||
|
||||
segmentsLayers
|
||||
}
|
||||
.mask(RoundedRectangle(cornerRadius: 3))
|
||||
|
||||
Circle()
|
||||
.strokeBorder(.gray, lineWidth: 1)
|
||||
@ -114,7 +113,7 @@ struct TimelineView: View {
|
||||
var projectedValue: Double {
|
||||
let change = (dragOffset / size.width) * units
|
||||
let projected = draggedFrom + change
|
||||
return projected.isFinite ? (duration - projected < (0.03 * duration) ? duration : projected) : start
|
||||
return projected.isFinite ? (duration - projected < (0.01 * duration) ? duration : projected) : start
|
||||
}
|
||||
|
||||
var thumbOffset: Double {
|
||||
|
@ -276,14 +276,17 @@ struct VideoPlayerView: View {
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Button {
|
||||
player.hide()
|
||||
} label: {
|
||||
Image(systemName: "xmark")
|
||||
.font(.system(size: 40))
|
||||
}
|
||||
.padding(10)
|
||||
.foregroundColor(.gray)
|
||||
#if os(iOS)
|
||||
Button {
|
||||
player.hide()
|
||||
} label: {
|
||||
Image(systemName: "xmark")
|
||||
.font(.system(size: 40))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.padding(10)
|
||||
.foregroundColor(.gray)
|
||||
#endif
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: geometry.size.width / Self.defaultAspectRatio)
|
||||
|
Loading…
Reference in New Issue
Block a user