使用UIWebView播放视频的错误



我正在尝试使用uiwebview播放视频,但是即使视频正在从服务器下载,也没有显示任何视频。有人知道我在这里做错了吗?

这是我的代码:

 override func viewDidLoad() {
    super.viewDidLoad()
    self.pdfView.delegate = self
    self.pdfView.mediaPlaybackRequiresUserAction = false
    if "" !=  video?.videoPath {
        self.loadFromUrl(path: (video?.videoPath)!)
        self.activityIND.isHidden = true
        self.activityIND.stopAnimating()
    } else {
        let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
        let strName = video?.id
        let filePath = "(documentsPath)/"+strName!+".wmv"
        let fileManager = FileManager.default
        self.activityIND.startAnimating()
        if fileManager.fileExists(atPath: filePath) {
            self.loadFromUrl(path: filePath)
            return;
        }

        let reference = FIRStorage.storage().reference(forURL: (self.video?.videoURL)!)
        reference.data(withMaxSize: 50 * 1024 * 1024) { (data, error) -> Void in
            if (error != nil) {
                print ("unable to download video file from Firebase Storage")
                self.activityIND.isHidden = false
                self.activityIND.startAnimating()
            } else {
                if ((try! data?.write(to: URL.init(fileURLWithPath: filePath, isDirectory: false))) != nil) {
                    self.loadFromUrl(path: filePath)
                    print ("video file is downloaded from Firebase Storage")
                    self.db.upDate(id: (self.video?.id)!, videoPath: filePath)
                    self.activityIND.isHidden = true
                }
            }
        }
    }
}

func loadFromUrl(path: String)
{
     let url =  NSURL(string:path)
        pdfView.loadRequest(NSURLRequest(url: url! as URL) as URLRequest)
        activityIND.isHidden = true
        activityIND.startAnimating()
}

结果不支持WMV格式,一旦我将格式更改为MP4,所有工作

相关内容

  • 没有找到相关文章

最新更新