I'm running a simple AVPlayer
in my app to play videos. When the play
method is called the video is extraordinarily slow. The first frame will load, then the video will stop, then play for a second, then stop again for an indefinite period. Once the video is fully downloaded then the app has no trouble playing the video. If I run the app on WiFi everything works great. It's when I run on 3G that everything hits the crapper.
Videos are only several seconds long and average out at 2mbs in size. I'm using Apple's Network Link Conditioner to simulate a 3G connection.
Here's the code I'm using thus far.
override func viewDidLoad() {
super.viewDidLoad()
playVideo()
}
func playVideo() {
let player = AVPlayer(URL: NSURL(string: "https://v.cdn.vine.co/r/videos/F55E4599581253064746484789248_4e75fe014aa.0.1.6509938863005525920.mp4")!)
player.volume = 0.5
player.actionAtItemEnd = AVPlayerActionAtItemEnd.None
let playerController = AVPlayerViewController()
playerController.player = player
playerController.showsPlaybackControls = false
self.addChildViewController(playerController)
self.view.addSubview(playerController.view)
playerController.view.frame = self.view.frame
player.play()
}
}
I also created a github repo with an example.
What's wrong and is there any way I can fix this to improve download speed?