Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

how to display progressbar during downloading video file from the server in to the iphone?

I have implemented video play functionality in iphone.In which i am downloading video file from the server and then play. But I want to display progress bar during downloading video file.For progressbar i need to calculate timing i don't know how to calculate time how much will take time for downloading video.

So please help me for this query.

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can get the expected total file size in the following callback method of NSURLConnection's NSURLConnectionDataDelegate:

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

then in following callback method you can calculate how much data has been received:

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

And you can use UIProgressView to show current downloading status on the screen.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...