Present the Editor
The camera and library can be bypassed by presenting the EditController with your own media.
Images
The below example presents the EditController with an image named “test_image” and sets the initial primary filter to Wilshire.
let image = UIImage(named: "test_image")!
let session = Session(image: image)
session.image!.primaryFilter = SessionFilterWilshire()
let editController = EditController(session: session)
editController.delegate = self
let nav = UINavigationController(rootViewController: editController)
nav.modalPresentationStyle = .fullScreen
self.present(nav, animated: true, completion: nil)
Videos
The below example presents the EditController with two AVAssets named “test.mov” and “test2.mp4” and sets the initial primary filter to Sepulveda. These two assets will become segments of the video in their respective order.
You can also manually pass a renderSize into the Session initializer. For more information see Session documentation.
let asset1 = AVAsset(url: Bundle.main.url(forResource: "test", withExtension: "mov")!)
let asset2 = AVAsset(url: Bundle.main.url(forResource: "test2", withExtension: "mp4")!)
let _ = Session(assets: [asset1, asset2], sessionReady: { (session, error) in
guard let session = session,
let video = session.video else {
print("Unable to create session: \(error!)")
return
}
// Set the initial primary filter to Sepulveda
video.primaryFilter = SessionFilterSepulveda()
let editController = EditController(session: session)
editController.delegate = self
let nav = UINavigationController(rootViewController: editController)
nav.modalPresentationStyle = .fullScreen
self.present(nav, animated: true, completion: nil)
})