Loading a local video file from PHPickerVC doesn't work in iOS 17

Created
Active
Viewed 131 times
1 replies

You must be a Member of the collective to start a discussion.

-7

I used PHPickerVC to load a local video files. It worked as well until iOS 16. However, getting failure for iOS 17. No problem with normal videos(most compatible), HEVC videos( which is recorded by apple default camera). But some hevc videos(ex, TikTok videos) are not loaded. These videos are recognized as "public.jpeg", not video format.

Here is my code to load videos from photo gallery.

private lazy var imagePickerController: UIImagePickerController = {
    let picker = UIImagePickerController()
    picker.delegate = self
    picker.allowsEditing = false
    picker.mediaTypes = ["public.movie"]
    picker.videoQuality = .typeHigh
    return picker
}()

func viewDidLoad() {
    self.present(self.phPickerController, animated: true, completion: nil)
}

extension YAVideoPicker: PHPickerViewControllerDelegate {
    func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
        picker.dismiss(animated: true, completion: nil)
        
        // When click "cancel" button
        guard !results.isEmpty else {
            return
        }

        guard let first = results.first else {
            return
        }

        let typeIdentifier = first.itemProvider.registeredTypeIdentifiers.first
        print("identifier", typeIdentifier)

        if first.itemProvider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) {
            first.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier, completionHandler: { [weak self] url, err in
                 if let url= url{
                  
                 }
            })
        }
    }
}

Tested environment: iOS 17.0.3, 17.1( Real device)

Why does some HEVC videos has public.jpeg identifier in iOS 17? Thus these videos can't be passed to "hasItemConformingToTypeIdentifier(UTType.movie.identifier)"

I've also tested apple's sample code but just same.

How can I solve this problem? I don't want to use PHAsset because don't want to request permission.

Thanks.

1 reply

Sorted by:
77500218
0

please fix the formatting of your post. see /help/formatting