8
Why does AVPlayer start playing this video 90% of the way through?
Post Body

Here's a random MP4 video of a car from Gfycat: https://thumbs.gfycat.com/IdolizedInformalKoalabear-mobile.mp4

When using with AVPlayer it starts playing 90% of the way through. On the next play through it starts playing from the beginning properly. This is causing a weird edge case with my code and I'm wondering if there's a reason AVPlayer is behaving like this that I can curtail or work with properly? Is it metadata in the video file indicating to do this?

Here's really simple sample code you can copy-paste into any view controller to test:

guard let url = URL(string: "https://thumbs.gfycat.com/IdolizedInformalKoalabear-mobile.mp4") else { return }
let player = AVPlayer(url: url)
let playerViewController = AVPlayerViewController()
playerViewController.player = player

present(playerViewController, animated: true) {
    player.play()
}

(Make sure you import AVKit)

Author
Account Strength
100%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,715,057
Link Karma
529,042
Comment Karma
607,499
Profile updated: 1 day ago
Posts updated: 1 month ago
Objective-C / Swift

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago