mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Layout and PiP improvements, new settings
- player is now a separate window on macOS - add setting to disable pause when player is closed (fixes #40) - add PiP settings: * Close PiP when starting playing other video * Close PiP when player is opened * Close PiP and open player when application enters foreground (iOS/tvOS) (fixes #37) - new player placeholder when in PiP, context menu with exit option
This commit is contained in:
@@ -94,7 +94,7 @@ struct InstancesSettings: View {
|
||||
}
|
||||
.labelsHidden()
|
||||
|
||||
Text("Used to create links from videos, channels and playlist")
|
||||
Text("Used to create links from videos, channels and playlists")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
40
macOS/OpenWindow.swift
Normal file
40
macOS/OpenWindow.swift
Normal file
@@ -0,0 +1,40 @@
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
||||
enum OpenWindow: String, CaseIterable {
|
||||
case player, main
|
||||
|
||||
var window: NSWindow? {
|
||||
// this is not solid but works as long as there is only two windows in the app
|
||||
// needs to be changed in case we ever have more windows to handle
|
||||
|
||||
switch self {
|
||||
case .player:
|
||||
return NSApplication.shared.windows.last
|
||||
case .main:
|
||||
return NSApplication.shared.windows.first
|
||||
}
|
||||
}
|
||||
|
||||
func focus() {
|
||||
window?.makeKeyAndOrderFront(self)
|
||||
}
|
||||
|
||||
var location: String {
|
||||
switch self {
|
||||
case .player:
|
||||
return rawValue
|
||||
case .main:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func open() {
|
||||
switch self {
|
||||
case .player:
|
||||
NSWorkspace.shared.open(URL(string: "yattee://player")!)
|
||||
case .main:
|
||||
Self.main.focus()
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,14 +11,14 @@ final class PictureInPictureDelegate: NSObject, AVPlayerViewPictureInPictureDele
|
||||
func playerViewWillStartPicture(inPicture _: AVPlayerView) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
||||
self?.playerModel.playingInPictureInPicture = true
|
||||
self?.playerModel.presentingPlayer = false
|
||||
self?.playerModel.hide()
|
||||
}
|
||||
}
|
||||
|
||||
func playerViewWillStopPicture(inPicture _: AVPlayerView) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
||||
self?.playerModel.playingInPictureInPicture = false
|
||||
self?.playerModel.presentPlayer()
|
||||
self?.playerModel.show()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ final class PictureInPictureDelegate: NSObject, AVPlayerViewPictureInPictureDele
|
||||
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: (Bool) -> Void
|
||||
) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
||||
self?.playerModel.presentingPlayer = true
|
||||
self?.playerModel.show()
|
||||
}
|
||||
completionHandler(true)
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import SwiftUI
|
||||
struct Player: NSViewControllerRepresentable {
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
|
||||
var controller: PlayerViewController?
|
||||
@State private var controller: PlayerViewController?
|
||||
|
||||
init(controller: PlayerViewController? = nil) {
|
||||
self.controller = controller
|
||||
|
Reference in New Issue
Block a user