I have a short video on my local machine. I am trying to open it using NSWorkspace
on QuickTime Player.
let stringUrl = "~/Desktop/myrec.mov"
let url = URL(string: stringUrl)!
let config = NSWorkspace.OpenConfiguration()
config.activates = true
NSWorkspace.shared.open(
[url],
withApplicationAt: URL(string: "~/Applications/QuickTime Player")!,
configuration: config
)
The error I am getting is:
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file cap/cap.swift
Which has to do with withApplicationAt
being the incorrect URL and returning nil
.
I'm sure withApplicationAtURL
is wrong, but I have no idea how to find the url for the quicktime player app.
I am very new to Swift and am having trouble reading the docs, especially since they don't seem up to date (e.g. my compiler says openFile
is deprecated and led me to open
).
I'm also not sure if this is the correct/best way to go about accomplishing what I am trying to do (open a small local video on quicktime player).
Any recommendations, tips, advice, or answers would be greatly appreciated!
question from:
https://stackoverflow.com/questions/65874089/open-a-short-video-using-quicktime-player 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…