PiP and UI improvements

This commit is contained in:
Arkadiusz Fal
2021-10-28 19:14:55 +02:00
parent c387454d9a
commit 24f7c566bf
18 changed files with 169 additions and 55 deletions

View File

@@ -47,8 +47,12 @@ struct Instance: Defaults.Serializable, Hashable, Identifiable {
URLComponents(string: apiURL)!
}
var frontendHost: String {
URLComponents(string: frontendURL!)!.host!
var frontendHost: String? {
guard let url = app == .invidious ? apiURL : frontendURL else {
return nil
}
return URLComponents(string: url)?.host
}
func hash(into hasher: inout Hasher) {

View File

@@ -1,4 +1,3 @@
import Defaults
import Foundation

View File

@@ -26,7 +26,7 @@ protocol VideosAPI {
func channelPlaylist(_ id: String) -> Resource?
func loadDetails(_ item: PlayerQueueItem, completionHandler: @escaping (PlayerQueueItem) -> Void)
func shareURL(_ item: ContentItem) -> URL
func shareURL(_ item: ContentItem) -> URL?
}
extension VideosAPI {
@@ -48,9 +48,13 @@ extension VideosAPI {
}
}
func shareURL(_ item: ContentItem) -> URL {
func shareURL(_ item: ContentItem) -> URL? {
guard let frontendHost = account.instance.frontendHost else {
return nil
}
var urlComponents = account.instance.urlComponents
urlComponents.host = account.instance.frontendHost
urlComponents.host = frontendHost
switch item.contentType {
case .video:

View File

@@ -13,7 +13,8 @@ final class PlayerModel: ObservableObject {
let logger = Logger(label: "net.arekf.Pearvidious.ps")
private(set) var player = AVPlayer()
var controller: PlayerViewController?
private(set) var playerView = Player()
var controller: PlayerViewController? { didSet { playerView.controller = controller } }
#if os(tvOS)
var avPlayerViewController: AVPlayerViewController?
#endif
@@ -52,6 +53,8 @@ final class PlayerModel: ObservableObject {
private var timeObserverThrottle = Throttle(interval: 2)
var playingInPictureInPicture = false
init(accounts: AccountsModel? = nil, instances: InstancesModel? = nil) {
self.accounts = accounts ?? AccountsModel()
self.instances = instances ?? InstancesModel()