0

クリックしてビデオを再生すると、このように表示されます。なぜだろうか。エラーは表示されません。AVKit と AVFoundation をインポートしました。また、デバイスとシミュレーターでテストしました。それでも機能しません。助言がありますか?どうもありがとう。

ここに画像の説明を入力

**Print log**
    //<PFFile: 0x79d472f0>
    //https://files.parsetfss.com/d9cdffff-4a1f-4bd9-b6ee-e60c07d49236/tfss-7e1636b9-5701-4737-9fa6-10609aec89e8-adsVido
    //<AVPlayer: 0x786f39b0>

// Click cell to play video.
    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        if adsVideoArray[indexPath.row] != nil {
            let theVideo:PFFile = adsVideoArray[indexPath.row]!
            print(theVideo)
            let url:NSURL = NSURL(string: theVideo.url!)!
            theVideo.getDataInBackgroundWithBlock({ (data:NSData?, error: NSError?) -> Void in
                if error == nil {
                    let player = AVPlayer(URL: url)
                    print(url)
                    print(player)
                    let playerController = AVPlayerViewController()
                    playerController.player = player
                    self.presentViewController(playerController, animated: true) {
                        player.play()
                    }
                }
            })
        }
    }

// load data from parse
    func loadAdsFromParse() {
        adsVideoArray.removeAll(keepCapacity: false)
        let query = PFQuery(className: "user_ads")
        query.findObjectsInBackgroundWithBlock({ (objects: [PFObject]?, error: NSError?) -> Void in
            for object in objects! {
                self.adsVideoArray.append(object.objectForKey("video") as? PFFile)
            }
            dispatch_async(dispatch_get_main_queue()) {
                self.adsCollectionView.reloadData()
            }
        })
    }

// the way to save video
    self.tempVideo = info[UIImagePickerControllerMediaURL] as! NSURL!
    let videoData = NSData(contentsOfFile:self.tempVideo.relativePath!)
    let videoFile:PFFile = PFFile(name:"adsVido", data:videoData!)!
    detailsObj["video"] = videoFile
    detailsObj.saveInBackgroundWithBlock{ ... }

// I tried to play the video before upload it to Parse. It works.
func playImageTapped(pressed: UIGestureRecognizer) {
    let player = AVPlayer(URL: tempVideo)
    let playerController = AVPlayerViewController()
    playerController.player = player
    self.presentViewController(playerController, animated: true) {
        player.play()
    }
}

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
    let mediaType = info[UIImagePickerControllerMediaType] as! NSString
    self.tempVideo = videoAdded
4

1 に答える 1