seanchas116 / SimpleDALPlugin

Simple CoreMediaIO DAL virtual camera plugin example written in Swift
MIT License
150 stars 19 forks source link

Question: how can we load images from plugin bundle? #13

Closed ldenoue closed 3 years ago

ldenoue commented 3 years ago

I tried but failed to load images from the plugin. I'd like to show a default background image in case my webcam is turned off by the user.

Something like self.backgroundImage = NSImage(named: "background.jpg") doesn't work. The only way was to load from the net. Ideas? Laurent

ldenoue commented 3 years ago

Answering my own question:

let bundlePath = Bundle(for: type(of: self)).bundlePath
let placeHolderPath = bundlePath + "/Contents/Resources/image.png"
let image = NSImage(contentsOfFile: placeHolderPath)