diff options
author | der richter <der.richter@gmx.de> | 2024-03-31 02:29:31 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2024-04-01 22:13:39 +0200 |
commit | d6c621b03beef1a38e66b33507a13e329e753383 (patch) | |
tree | c04394c74c74cb6b43d3f63fb1ab70a9bbf0735a /osdep | |
parent | 2c7e4f59353705702224429f6a9b247f3ca6949e (diff) | |
download | mpv-d6c621b03beef1a38e66b33507a13e329e753383.tar.bz2 mpv-d6c621b03beef1a38e66b33507a13e329e753383.tar.xz |
mac/apphub: move opening url into AppHub
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/mac/app_hub.swift | 13 | ||||
-rw-r--r-- | osdep/mac/application.swift | 12 |
2 files changed, 14 insertions, 11 deletions
diff --git a/osdep/mac/app_hub.swift b/osdep/mac/app_hub.swift index cbb4e2b6a5..a46bdc87c7 100644 --- a/osdep/mac/app_hub.swift +++ b/osdep/mac/app_hub.swift @@ -36,6 +36,7 @@ class AppHub: NSObject { var cocoaCb: CocoaCB? #endif + let MPV_PROTOCOL: String = "mpv://" var isApplication: Bool { get { NSApp is Application } } private override init() { @@ -88,6 +89,18 @@ class AppHub: NSObject { #endif } + func open(urls: [URL]) { + let files = urls.map { + if $0.isFileURL { return $0.path } + var path = $0.absoluteString + if path.hasPrefix(MPV_PROTOCOL) { path.removeFirst(MPV_PROTOCOL.count) } + return path.removingPercentEncoding ?? path + }.sorted { (strL: String, strR: String) -> Bool in + return strL.localizedStandardCompare(strR) == .orderedAscending + } + input.open(files: files) + } + func getIcon() -> NSImage { guard let iconData = app_bridge_icon(), let icon = NSImage(data: iconData) else { return NSImage(size: NSSize(width: 1, height: 1)) diff --git a/osdep/mac/application.swift b/osdep/mac/application.swift index ee5ee8eea2..086b6eff66 100644 --- a/osdep/mac/application.swift +++ b/osdep/mac/application.swift @@ -19,8 +19,6 @@ import Cocoa class Application: NSApplication, NSApplicationDelegate { var appHub: AppHub { get { return AppHub.shared } } - let MPV_PROTOCOL: String = "mpv://" - var playbackThreadId: mp_thread! var argc: Int32? var argv: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>? @@ -75,15 +73,7 @@ class Application: NSApplication, NSApplicationDelegate { #endif func application(_ application: NSApplication, open urls: [URL]) { - let files = urls.map { - if $0.isFileURL { return $0.path } - var path = $0.absoluteString - if path.hasPrefix(MPV_PROTOCOL) { path.removeFirst(MPV_PROTOCOL.count) } - return path.removingPercentEncoding ?? path - }.sorted { (strL: String, strR: String) -> Bool in - return strL.localizedStandardCompare(strR) == .orderedAscending - } - appHub.input.open(files: files) + appHub.open(urls: urls) } func applicationWillFinishLaunching(_ notification: Notification) { |