mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Minor improvements
This commit is contained in:
@@ -183,11 +183,6 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
}
|
||||
#endif
|
||||
|
||||
func updateControls() {}
|
||||
func startControlsUpdates() {}
|
||||
func stopControlsUpdates() {}
|
||||
func setNeedsDrawing(_: Bool) {}
|
||||
|
||||
private func loadSingleAsset(
|
||||
_ url: URL,
|
||||
stream: Stream,
|
||||
@@ -564,4 +559,10 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateControls() {}
|
||||
func startControlsUpdates() {}
|
||||
func stopControlsUpdates() {}
|
||||
func setNeedsDrawing(_: Bool) {}
|
||||
func setSize(_: Double, _: Double) {}
|
||||
}
|
||||
|
@@ -152,6 +152,10 @@ final class MPVBackend: PlayerBackend {
|
||||
isPlaying = true
|
||||
startClientUpdates()
|
||||
|
||||
if controls.presentingControls {
|
||||
startControlsUpdates()
|
||||
}
|
||||
|
||||
client?.play()
|
||||
}
|
||||
|
||||
@@ -305,4 +309,8 @@ final class MPVBackend: PlayerBackend {
|
||||
func setNeedsDrawing(_ needsDrawing: Bool) {
|
||||
client?.setNeedsDrawing(needsDrawing)
|
||||
}
|
||||
|
||||
func setSize(_ width: Double, _ height: Double) {
|
||||
self.client?.setSize(width, height)
|
||||
}
|
||||
}
|
||||
|
@@ -168,14 +168,23 @@ final class MPVClient: ObservableObject {
|
||||
}
|
||||
|
||||
func setSize(_ width: Double, _ height: Double) {
|
||||
logger.info("setting player size to \(width),\(height)")
|
||||
let roundedWidth = width.rounded()
|
||||
let roundedHeight = height.rounded()
|
||||
|
||||
guard width > 0, height > 0 else {
|
||||
return
|
||||
}
|
||||
|
||||
logger.info("setting player size to \(roundedWidth),\(roundedHeight)")
|
||||
#if !os(macOS)
|
||||
guard width <= UIScreen.main.bounds.width, height <= UIScreen.main.bounds.height else {
|
||||
guard roundedWidth <= UIScreen.main.bounds.width, roundedHeight <= UIScreen.main.bounds.height else {
|
||||
logger.info("requested size is greater than screen size, ignoring")
|
||||
logger.info("width: \(roundedWidth) <= \(UIScreen.main.bounds.width)")
|
||||
logger.info("height: \(roundedHeight) <= \(UIScreen.main.bounds.height)")
|
||||
return
|
||||
}
|
||||
|
||||
glView?.frame = CGRect(x: 0, y: 0, width: width, height: height)
|
||||
glView?.frame = CGRect(x: 0, y: 0, width: roundedWidth, height: roundedHeight)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -50,6 +50,7 @@ protocol PlayerBackend {
|
||||
func stopControlsUpdates()
|
||||
|
||||
func setNeedsDrawing(_ needsDrawing: Bool)
|
||||
func setSize(_ width: Double, _ height: Double)
|
||||
}
|
||||
|
||||
extension PlayerBackend {
|
||||
|
@@ -101,6 +101,10 @@ final class PlayerControlsModel: ObservableObject {
|
||||
}
|
||||
|
||||
func resetTimer() {
|
||||
if !presentingControls {
|
||||
show()
|
||||
}
|
||||
|
||||
removeTimer()
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false) { _ in
|
||||
withAnimation(PlayerControls.animation) { [weak self] in
|
||||
|
@@ -42,7 +42,9 @@ final class PlayerModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Published var playerSize: CGSize = .zero
|
||||
@Published var playerSize: CGSize = .zero { didSet {
|
||||
backend.setSize(playerSize.width, playerSize.height)
|
||||
}}
|
||||
@Published var stream: Stream?
|
||||
@Published var currentRate: Float = 1.0 { didSet { backend.setRate(currentRate) } }
|
||||
|
||||
|
@@ -66,7 +66,7 @@ extension PlayerModel {
|
||||
|
||||
func rebuildTVMenu() {
|
||||
#if os(tvOS)
|
||||
controller?.playerView.transportBarCustomMenuItems = [
|
||||
avPlayerBackend.controller?.playerView.transportBarCustomMenuItems = [
|
||||
restoreLastSkippedSegmentAction,
|
||||
rateMenu,
|
||||
streamsMenu
|
||||
|
Reference in New Issue
Block a user