Need class structure to call Swift AVPlayer video (swift 5)

Job ID: 32032766

Budget: $10 – $30 USD

We have two classes, a view controller and data retrieval class. The view controller contains a function to play a video based on a local file path. The utilities class pulls the URLs from core data and calls a function in the video controller path. When I call playVideo from viewcontroller it works fine. When I instruct the viewcontroller to call the retrieval function which then call same function from the utilities class nothing happens. Don’t have any more time work on. No other code is needed- all of the code to retrieve data from CoreData is working currently. If you can fix this quick, please let me know. Please don’t reply with generic 7-day estimates.

Here's an overview of the structure-

Class VideoViewerController : UIViewController {

Var avPlayer: AVPlayer!
Var layer = AVPlayerLayer()

Override func viewWillAppear(_animated: Bool){
DataRetrieval().GetUrlsFromCoreData()
}

Func playVideo(videoFilePath : String ,completionHandler : @escaping (String) -> void ){
avPlayer = AVPlayer(url: URL ( fileURLWithPath : videoFilePath)
layer = AVPlayerLayer(player : avPlayer)
layer.frame = self.view.bounds
view.layer.addSublayer(layer)
avPlayer.play()
}
}

Class DataRetrieval{

Func GetUrlsFromCoreData(){

//Code gets URL from Coredata
VideoViewerController().playVideo(videoFilePath: "someUrltoVideoSource"){[self] (playVideoResults) in
Print(videoFilePath)
}
}
}
Related categories: Objective C Swift iOS Development