简体   繁体   中英

tmp video file accessible to AVPlayer on simulator but not device

My app edits a video and exports the edited version. I have the app running with no problems in the simulators, but when I try to preview the edited version of the video on a device I am not able to. I've tried all the de-bugging I could think of but still stuck.

I'm creating the export URL with the following code:

 let videoName = UUID().uuidString
 let exportURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(videoName).appendingPathExtension("mov")

Which gives me the following URL:

file:///private/var/mobile/Containers/Data/Application/DB9E4828-D869-4A67-A0C1-E0BA5FA25772/tmp/2019E9B5-1004-46F7-BF86-2133BDD533DF.mov

It seems like it should be working but the video is not playing. I've verified the playerLayer is being added to the view, but no video. Again, the app works on the simulator, so that leads me to believe it's a file access issue.

Does anyone see an issue with the URL I'm getting, or have any ideas as to what could be wrong?

This url is mac computer with simulator, so there are not this url on the real device.You need to give the video for network or using the arguments.

How to play a local video with Swift?

This arguments using the Bundle Resource.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM