I need to show the current Progress of the video played using MPMoviePlayerController in a UILabel. I need to show the current progress and the total duration of the video in a UILable. It should look something like 1.25/5.00 ? I need to show this when the video is playing. I can show it directly with the Default Progress Bar but i need to disable it. As i am not able to disable it i am planning to show the current progress of the video in a UILabel. Can someone please provide any suggestion on this?
Asked
Active
Viewed 3,892 times
1
-
It sounds like you have two questions. #1) how to disable the default progress bar and #2) how to get the current progress as a property that you can put into a label somewhere else. Am I correct in this? – Michael Dautermann Jun 05 '12 at 11:03
-
@MichaelDautermann: Yes Michael. I was actually looking on how to disable the default progress bar. But i was not able to find how to do that. So i just thought of hiding the controls using MPMovieControlStyleNone. But my requirement is to definitely the progress of the Video... – Pradeep Reddy Kypa Jun 05 '12 at 11:08
3 Answers
3
well to set the progress and the durations, u can call a self watcher after playing the video and then update the value of progress Label...
you set the observer to see when the player started playing and in the selector u call to the watcher, this watcher should look something like this;
-(void)watcher{
urProgressLabel.text = [NSString stringWithFormat:@"%d",movieplayer.currentPlaybackTime];
[self performSelector:@selector(watcher) withObject:nil afterDelay:0.5];//to update the value each 0.5 seconds
}
Hope it helps ;)

Pradeep Reddy Kypa
- 3,992
- 7
- 57
- 75

Calleth 'Zion'
- 613
- 3
- 15
2
Got the Answer...
When Instantiating the Video Player...
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
//Add the Label to show the Progress of the Video....
progressLabel = [[UILabel alloc]initWithFrame:CGRectMake(125,275,70,25)];
progressLabel.backgroundColor = [UIColor clearColor];
[progressLabel setTextColor:[UIColor whiteColor]];
[self.view addSubview:progressLabel];
//set a Timer..
[NSTimer scheduledTimerWithTimeInterval:1.0f
target:self
selector:@selector(updatePlaybackTime:)
userInfo:nil
repeats:YES];
and in the Method updatePlaybackTime: ....
- (void)updatePlaybackTime:(NSTimer*)theTimer {
progressLabel.text = [NSString stringWithFormat:@"%f",self.moviePlayerController.currentPlaybackTime];
}
Done..U will have the Label updated with the progress of the Video...

Pradeep Reddy Kypa
- 3,992
- 7
- 57
- 75
-
yes this work too but the timer will continue even if u pause the player what means that u are wasting resources ;) – Calleth 'Zion' Jun 06 '12 at 09:06
-
and u have to use MPMoviePlayerViewController... is nicer than MPMoviePlayerController ;) – Calleth 'Zion' Jun 06 '12 at 09:07
-
I am having another notification to notify when the video pauses and stops. SO in that method, i am invalidating the timer. I just havent mentioned that in the above example.... Apart from this, How different is MPMoviePlayerViewController different from MPMoviePlayerController??? What extra does this provide other than ones provided by MPMoviePlayerController?? – Pradeep Reddy Kypa Jun 07 '12 at 02:01
-
Well in xcode 3 there was an message about replacing MPMoviePlayerController to MPMoviePlayerViewController cause the first one would be depreciated, and for your timer u should get a interval of 0.5 cause if a video has a duration of .5 u should show another second... – Calleth 'Zion' Jun 07 '12 at 09:27
-
and with movieplayer controller if u make a gesture of two fingers separating them the video will go to full screen mode, im sure that if u want to show the custm duration you dont want to enable this mode ;) – Calleth 'Zion' Jun 11 '12 at 11:02