从Alamofire下载的视频无法在横向模式下播放

时间:2018-12-13 09:58:30

标签: ios swift alamofire

我正在通过Alamofire下载视频,当我在任何与swift兼容的播放器中播放该视频时,该视频仅以纵向模式播放。我还需要在横向模式下播放视频。这是我的代码-

'      request = Alamofire.download(videoImageUrl !, to:destination).downloadProgress      {进度

   self.isDownloading = true

        print("\(floor(progress.fractionCompleted*100))%")
        self.downloadingView.downloadPercentagaeView.text = "\(Int(floor(progress.fractionCompleted*100)))% of \(String(format: "%.1f", (Double(sizeOfVideo) * 0.000001)))MB"
        }

        .response { response in
          if let error = response.error {
            print(error)
            if self.isDownloadCancelled == false {
          if !HasfitHelper.shared.isInternetConnected {

            let internetErrorView = internetDisconnectedView.internetAlertView() as! UIView

            internetErrorView.frame = UIScreen.main.bounds
            internetDisconnectedView.internetDisconectedDelegate = self
            HasfitHelper.mainWindow().rootViewController?.view.addSubview(internetErrorView)

              }
              if response.resumeData != nil {
              self.dataCache.set(response.resumeData!, forKey: videoImageUrl!)
              print(self.dataCache.value(forKey: videoImageUrl!) as Any)
              }}

          if self.isDownloadCancelled == true
          {
            self.dataCache.set(nil, forKey: videoImageUrl!)
            print(self.dataCache.value(forKey: videoImageUrl!) as Any)
            return
          }
         }
          if response.destinationURL != nil {

            print(response.destinationURL!)



            self.downloadVideoForOfflineButton.setImage(UIImage(named:"download_filled_icon"), for: .normal)
            self.isDownloaded = true
            self.offlineVideoUrl = "\(response.destinationURL!)"
            self.dataCache.set(nil, forKey: videoImageUrl!)



            self.tableView.reloadData()
            if self.isfavorite == false {
              self.rightPressed(self)
            }
            let remoteImageURL = URL(string: (self.workoutInfoDict[kAPIParam.thumbnail] as? String)!)
            Alamofire.request(remoteImageURL!).responseData { (responseImage) in
              if responseImage.error == nil {
                print(responseImage.result)
                let dict = ["post_id":self.postID,"file_url":"\(response.destinationURL!)","thumbnail":self.workoutInfoDict[kAPIParam.thumbnail]!,"post_name":self.workoutInfoDict[kAPIParam.postName]!,"thumbnailData":responseImage.data!] as [String : Any]

                var offlineDict = UserDefaults.standard.value(forKey: "offlineDict") as! [Any]
                offlineDict.append(dict)
                UserDefaults.standard.set(offlineDict, forKey: "offlineDict")
                UserDefaults.standard.synchronize()
                self.downloadingView.removeFromSuperview()
                self.isDownloading = false
}

'

1 个答案:

答案 0 :(得分:0)

请在应用的info.p列表中检查设备方向。

要获取横向视频,您可能需要检查应用的横向模式。

尽管我不确定这是否可以解决您的问题,但值得尝试。

enter image description here