views:

1068

answers:

5

Is it possible to use chapters in videos for the iPhone in an application?

For example: I have a 3 minutes video to play. I have chapter 1 starting at 0s, chapter 2 at 50s, chapter 3 at 95s.

Can I start plating the video at 50s (chapter 2) until the end? Can I make it play just the chapter 2 from 50s to 95s?

My question is not about how to add chapters to a video. I want to know if this behaviour is available on the iphone.

A: 

This is definitely possible sending the non-documented message setCurrentTime to MPMoviePlayerController. It takes one parameter of type double which specifies the playback position in seconds. Find below a short example:

Extend the MPMoviePlayerController to avoid compiler warnings:

@interface MPMoviePlayerController (extended)
-(void)setCurrentTime:(double)seconds;
@end

Then you can call it wherever you need it - before start or during playback.

MPMoviePlayerController* player = [[ MPMoviePlayerController alloc] initWithContentURL:url ];
[ player setCurrentTime:95.0 ];
[ player play ];
Vladimir Grigorov
Apple started rejecting apps that use unpublished APIs. And even if your app is accepted, it may break after any OS update. Do _not_ use unpublished APIs like this in App Store applications, however compelling it may be.
Andrey Tarantsov
+3  A: 

iPhone SDK 3.0+ has a new MPMoviePlayerController.initialPlaybackTime property for setting the time to start movie playback. This will be "rounded" to the nearest earlier keyframe time, so does not provide exact start positioning, but pretty close.

Jason
the problem is, not all videos have a lot keyframes. This function can cause accuracy problems when the keyframe time is far away from required time.
Shivan Raptor
A: 

doesn't work for me, unfortunately

i tried the same code as above, but whenever i try to invoke [player setCurrentTime:1.0], the app crashes with the exception

"[MPMoviePlayerController setCurrentTime:] unrecognized selector sent to instance"

can anybody help me with this problem? is there anything else i should do to make the code work?

kate
A: 

any luck gettings this code to work?

I have the same problem exactly

Alon
A: 

player.currentPlaybackTime = time;

dizy