How to display progress bar while uploading video from server to iphone?

I implemented the video playback function in iphone. In which I download a video file from the server, and then play. But I want to display a progress bar while the video is loading. To switch to progress, I have to calculate the time when I do not know how to calculate the time, how long it takes to download the video.

Therefore, please help me in this matter.

Thanks in advance.

+4
source share
1 answer

You can get the expected total file size in the following NSURLConnection NSURLConnectionDataDelegate callback NSURLConnectionDataDelegate :

 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { self.expectedTotalSize = response.expectedContentLength; } 

then in the following callback method you can calculate how much data was received:

 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { self.recievedData += data.length; } 

And you can use UIProgressView to display the current download status on the screen.

+7
source

All Articles