Minor improvements

This commit is contained in:
Arkadiusz Fal 2022-02-21 21:57:12 +01:00
parent 1d24705c92
commit 4081c65c34
7 changed files with 393 additions and 108 deletions

0
ISSUE_TEMPLATE.md Normal file
View File

View File

@ -52,8 +52,9 @@ final class PlayerControlsModel: ObservableObject {
} }
func show() { func show() {
withAnimation(PlayerControls.animation) {
player.backend.updateControls() player.backend.updateControls()
withAnimation(PlayerControls.animation) {
presentingControls = true presentingControls = true
} }
} }
@ -65,11 +66,11 @@ final class PlayerControlsModel: ObservableObject {
} }
func toggle() { func toggle() {
withAnimation(PlayerControls.animation) {
if !presentingControls { if !presentingControls {
player.backend.updateControls() player.backend.updateControls()
} }
withAnimation(PlayerControls.animation) {
presentingControls.toggle() presentingControls.toggle()
} }
} }

View File

@ -300,6 +300,9 @@ final class PlayerModel: ObservableObject {
} }
private func handleNavigationViewPlayerPresentationChange() { private func handleNavigationViewPlayerPresentationChange() {
backend.setNeedsDrawing(playerNavigationLinkActive)
controls.hide()
if pauseOnHidingPlayer, !playingInPictureInPicture, !playerNavigationLinkActive { if pauseOnHidingPlayer, !playingInPictureInPicture, !playerNavigationLinkActive {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.pause() self.pause()

View File

@ -2,7 +2,7 @@ import Foundation
import SwiftUI import SwiftUI
struct PlayerControls: View { struct PlayerControls: View {
static let animation = Animation.easeInOut(duration: 0) static let animation = Animation.easeInOut(duration: 0.2)
private var player: PlayerModel! private var player: PlayerModel!
@ -60,12 +60,8 @@ struct PlayerControls: View {
} }
var controlsBackground: some View { var controlsBackground: some View {
model.presentingControls ?
AnyView(
PlayerGestures() PlayerGestures()
.background(Color.black.opacity(0.5)) .background(Color.black.opacity(model.presentingControls ? 0.5 : 0))
) :
AnyView(Color.clear)
} }
var timeline: some View { var timeline: some View {
@ -145,7 +141,7 @@ struct PlayerControls: View {
HStack { HStack {
fullscreenButton fullscreenButton
Spacer() Spacer()
button("Music Mode", systemImage: "music.note") // button("Music Mode", systemImage: "music.note")
} }
} }

View File

@ -33,14 +33,14 @@ final class MPVOGLView: GLKView {
glClear(UInt32(GL_COLOR_BUFFER_BIT)) glClear(UInt32(GL_COLOR_BUFFER_BIT))
} }
override func draw(_: CGRect) { override func draw(_ rect: CGRect) {
glGetIntegerv(UInt32(GL_FRAMEBUFFER_BINDING), &defaultFBO!) glGetIntegerv(UInt32(GL_FRAMEBUFFER_BINDING), &defaultFBO!)
if mpvGL != nil { if mpvGL != nil {
var data = mpv_opengl_fbo( var data = mpv_opengl_fbo(
fbo: Int32(defaultFBO!), fbo: Int32(defaultFBO!),
w: Int32(bounds.size.width) * Int32(contentScaleFactor), w: Int32(rect.size.width) * Int32(contentScaleFactor),
h: Int32(bounds.size.height) * Int32(contentScaleFactor), h: Int32(rect.size.height) * Int32(contentScaleFactor),
internal_format: 0 internal_format: 0
) )
var flip: CInt = 1 var flip: CInt = 1

View File

@ -114,6 +114,7 @@ struct VideoPlayerView: View {
Color.clear Color.clear
.onAppear { .onAppear {
player.playerSize = proxy.size player.playerSize = proxy.size
// TODO move to backend method
player.mpvBackend.client?.setSize(proxy.size.width, proxy.size.height) player.mpvBackend.client?.setSize(proxy.size.width, proxy.size.height)
} }
.onChange(of: proxy.size) { _ in .onChange(of: proxy.size) { _ in

File diff suppressed because it is too large Load Diff