2
votes

What I'm doing currently is that, I have a remote URL containing a MP4 file. I download that into a file using NSData and NSFileManager (as I want to cache the file). Now I start to play the file using AVPlayer.

All this works. But the problem is,when the video is getting buffered after a few seconds, the playback cannot be resumed.

Note:

The state of the AVPlayer does not change to Pause.

The current time of the video continues to run even though the video has stalled.

Is there anyway I can pause the video before the buffer happens? Thanks in advance.

1
Interesting question but without providing the problematic code it is extremely difficult to help you.Carl Veazey
@CarlVeazey not sure which part of the code to paste here honestly. Can we chat sometime?I'll share the code with you then.Anil
you could show how you synchronize / time downloading the file and starting playback.Carl Veazey
Here's my viewDidLoad Here's the connection delegates link and the method playMovie is used to play the file.Anil
I solved it myself calculating the size of the buffer coming inAnil

1 Answers

1
votes

Fixed it myself. Created a file and the downloaded data is written into the file only after say 1MB of it has been downloaded and the player is made to pause when say 90% of this data has been read. This way the player doesn't stall.In the background the file continues to be downloaded. This way the size of the file will continue to increase even if the player is playing/pausing the video.