如何使用 URL 方案打开 vlc

How can I open vlc with a URL scheme

如何用URL方案打开vlc? 我目前在本地存储了一个名为 video 的视频文件,但收到错误消息:

         "Unexpectedly found nil while unwrapping an Optional value"  

代码

           let vlcURL = "vlc://video.mp4"
           let vlcItem = ("vlc", URL(string:vlcURL)!)  //i recive the error her

          var installedvideoApps = [("Vlc", URL(string:vlcURL)!)]

           if UIApplication.shared.canOpenURL(vlcItem.1) {
               installedvideoApps.append(vlcItem)
           }

           let alert = UIAlertController(title: "Selection", message: "Select Video App",   
           preferredStyle: .actionSheet)

           for app in installedvideoApps {
               let button = UIAlertAction(title: app.0, style: .default, handler: { _ in
                   UIApplication.shared.open(app.1, options: [:], completionHandler: nil)
               })
               alert.addAction(button)
           }
           let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
           alert.addAction(cancel)
           present(alert, animated: true)

尝试使用 addingPercentEncoding(withAllowedCharacters:)URL 添加编码。

let vlcURL = "vlc://video.mp4".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
let vlcItem = ("vlc", URL(string:vlcURL)!)