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