Is it possible to record video while another video plays in the upper most layers?

I want to find out whether it is possible to record video by accessing the device’s camera through the AVFoundation framework , while another video is played back at the top level through MPMoviePlayerController ? I tried this thing to add the MPMoviePlayerController view on top of the VideoPreviewLayer for the AVFoundation framework . But when I call the recording method, I get the error message: "The captured file could not be written to the resource library. This is most likely an audio file."

+6
source share
1 answer

It is possible. What you need to do is create a video preview layer, as you did before. Then follow these steps:

 MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: myURL]; [player prepareToPlay]; [player.view setFrame: myView.bounds]; // player frame must match parent's [self.view addSubview: player.view]; [player play]; 

This should place the MPMoviePlayerController over the video preview layer. If you still get the error, let me know in the comments, you can do something wrong with AVFoundation .

0
source

Source: https://habr.com/ru/post/900913/


All Articles