Play video on xcode simulator but not on device

I created a page for my project with a video (2.1 Mb / 480p) that plays in a loop. The video plays on my simulator, but not when I download the application on the iPhone. I checked several posts with the same question, but so far none of the solutions have worked. What could be causing this problem? How can i solve this?

My video is stored locally. Here is the corresponding source code that plays my video:

override func viewDidAppear(animated: Bool) {

        let fileUrl = NSURL(fileURLWithPath: "/Users/User/Desktop/Project_XYZ/Pultz/11005472.mp4")
        playerView = AVPlayer(URL: fileUrl)

        let playerLayer = AVPlayerLayer(player: playerView)
        playerLayer.frame = videoContainer.frame
        playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill


        //playerViewController.player = playerView

        self.view.layer.addSublayer(playerLayer)
        playerView.play()

        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(WorkoutDashboardViewController.restart), name: AVPlayerItemDidPlayToEndTimeNotification, object: self.playerView.currentItem)

    }

PS The video I use is a free watermark that I got from the Internet. Could this be a likely cause?

+4
source share
1 answer

:

let fileUrl = NSURL(fileURLWithPath: "/Users/User/Desktop/Project_XYZ/Pultz/11005472.mp4")

:

let fileUrl = NSURL(fileURLWithPath:  NSBundle.mainBundle().pathForResource("11005472", ofType: "mp4"))

iPhone . , /.

+3

Source: https://habr.com/ru/post/1649264/


All Articles