Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在photoLibrary UIimgaePickerController swift中筛选扩展_Swift_Video_Filter_Uiimagepickercontroller_Mp4 - Fatal编程技术网

如何在photoLibrary UIimgaePickerController swift中筛选扩展

如何在photoLibrary UIimgaePickerController swift中筛选扩展,swift,video,filter,uiimagepickercontroller,mp4,Swift,Video,Filter,Uiimagepickercontroller,Mp4,我只想在图书馆里有一种类型的视频。使用默认库。我的应用程序当前正在使用UIImagePickerController.photoLibrary从应用程序文档目录拍摄图像和视频。我只想显示一种视频类型 import AVFoundation import MobileCoreServices import Photos import UIKit class CameraLibraryTestViewController: UIViewController { @IBOutlet

我只想在图书馆里有一种类型的视频。使用默认库。我的应用程序当前正在使用UIImagePickerController.photoLibrary从应用程序文档目录拍摄图像和视频。我只想显示一种视频类型

import AVFoundation
import MobileCoreServices
import Photos
import UIKit

 class CameraLibraryTestViewController: UIViewController {
        @IBOutlet weak var imgView: UIImageView!

        let picker = UIImagePickerController()


        override func viewDidLoad() {
            super.viewDidLoad()


        }

        @IBAction func bAction(_ sender: Any) {
            picker.mediaTypes = ["public.image", "public.mp4"] // filter extesion mp4 didn't work, 
            picker.sourceType = .photoLibrary
            picker.allowsEditing = false
            picker.delegate = self

            present(picker, animated: true)
        }
    }



    extension CameraLibraryTestViewController: UINavigationControllerDelegate, UIImagePickerControllerDelegate {
        public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
            dismiss(animated: true, completion: nil)
        }

        func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
            viewController.navigationItem.title = "Jeri Library"
            picker.setEditing(false, animated: true)
            print("test or check: \(viewController.debugDescription)")
        }

        func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
            let assetPath = info[UIImagePickerControllerReferenceURL] as! NSURL

            if (assetPath.absoluteString?.hasSuffix("MOV"))! {
                print("MOV")
                dismiss(animated: true) {
                    self.navigationController?.pushViewController(EmojiReadViewController(), animated: true)
                }
            }
            else if (assetPath.absoluteString?.hasSuffix("MP4"))! {
                print("MP4")
                dismiss(animated: true) {
                    self.navigationController?.pushViewController(EmojiReadViewController(), animated: true)
                }
            }
            else if (assetPath.absoluteString?.hasSuffix("M4V"))! {
                print("M4V")
                dismiss(animated: true) {
                    self.navigationController?.pushViewController(EmojiReadViewController(), animated: true)
                }
            }
            else {
                print("Unknown")
                dismiss(animated: true, completion: nil)
            }
        }
    }
我尝试使用mediaType[kUTTypeMPEG4 as String],但仍然不起作用,这是在didFinishPickingMediaWithInfo中,它仅用于从库中选择后的过滤器


如果我使用kUTTypeMovie,它会获取本地存储中的所有视频

这将只显示视频

picker.mediaTypes = [ "public.movie"]

你解决了吗?@EssamMohamed在2018年解决了,谢谢让_extension=posibleVideoURL.pathExtension.lowercased如果_extension==mov | | | u extension==mp4{}在哪里写这些行?他只要求mp4视频!