Swift AVPlayer will not be MP4 player: line play button

enter image description here

I am trying to play mp4 video from a local file system in an ios application. The video lasts about an hour and can be played in quick play mode. I can play mp4 if it is from the Internet (NSURL (line: "http: domain.com/vid.mp4")). I am playing a video as shown below:

let steamingURL:NSURL = NSURL(string: video.filePath)! //valid path let player = AVPlayer(URL: steamingURL) player.allowsExternalPlayback = false PlayWorkoutViewController.playerController = AVPlayerViewController() PlayWorkoutViewController.playerController.player = player self.addChildViewController(PlayWorkoutViewController.playerController) self.view.addSubview(PlayWorkoutViewController.playerController.view) PlayWorkoutViewController.playerController.view.frame = videoContainerView.frame PlayWorkoutViewController.playerController.showsPlaybackControls = false player.play() 

Do I need to change some settings to play a longer video? Thanks.

+5
source share
1 answer

Verify that steamingURL is zero or not the first.

If you want to use the NSURL initializer (string: "xxx"), check to see if the line starts with the file: //, otherwise NSURL (fileURLWithPath: "xxxx") is used.

+7
source

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


All Articles