Hi
I'm trying to seamlessly loop a video in two ways - using the MediaPlayer framework (which fades in at the start and out at the end, which is no good - even if you load a still frame into the main view as a background, the MP seems to fade to and from black), or by animating the frames (which kills the phone if you use to many).
Framework example:
Code:
-(void)awakeFromNib {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"MyMovie" ofType:@"m4v"];
NSURL *movieURL;
if (moviePath)
{
movieURL = [NSURL fileURLWithPath:moviePath];
}
if (movieURL != nil) {
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
moviePlayer.movieControlMode = MPMovieControlModeHidden;
//moviePlayer.backgroundColor = [UIColor blackColor];
[moviePlayer play];
}
}
-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
moviePlayer = [notification object];
[moviePlayer play];
}
The animation example
Code:
- (void)viewDidLoad {
// create the view that will execute our animation
UIImageView* exampleView = [[UIImageView alloc] initWithFrame:self.view.frame];
// load all the frames of our animation
exampleView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"e001.jpg"],
...
[UIImage imageNamed:@"e451.jpg"],nil];
// all frames will execute in 1.75 seconds
exampleView.animationDuration = 15;
// repeat the annimation forever
exampleView.animationRepeatCount = 0;
// start animating
[exampleView startAnimating];
// add the animation view to the main window
[self.view addSubview:exampleView];
[exampleView release];
}
Can anyone suggest a better way to seamlessly loop a 15 second video?
Thanks for that - I decided to go with the MediaPlayer method because you can set the background color to be clear, which means the still frame shows through while the video fades in/out. Oddly if I have my phone plugged in to XCode and Run the app it works great, but if I run the app on the phone with it untethered I get a moment of black between each run of the video (this is my first iPhone app by the way) - why would that be? Do I need to put a release version on my phone to make it play smoothly?
Cheers
i've tried the same thing - but my video fickers when I re-play it... It seem the background is showing every several ms. - the problem doubles every time i replay the movie.
does anyone have a solution for this ?
Quote:
Originally Posted by pr0fess0r
Thanks for that - I decided to go with the MediaPlayer method because you can set the background color to be clear, which means the still frame shows through while the video fades in/out. Oddly if I have my phone plugged in to XCode and Run the app it works great, but if I run the app on the phone with it untethered I get a moment of black between each run of the video (this is my first iPhone app by the way) - why would that be? Do I need to put a release version on my phone to make it play smoothly?
Cheers
i've tried the same thing - but my video fickers when I re-play it... It seem the background is showing every several ms. - the problem doubles every time i replay the movie.
Thanks for that - I decided to go with the MediaPlayer method because you can set the background color to be clear, which means the still frame shows through while the video fades in/out. Oddly if I have my phone plugged in to XCode and Run the app it works great, but if I run the app on the phone with it untethered I get a moment of black between each run of the video (this is my first iPhone app by the way) - why would that be? Do I need to put a release version on my phone to make it play smoothly?
Cheers
Hey, I know it's been a long time, but did you ever figure this out?? I desperately, need to do the same thing. I have two different clips. Once one finished, the other plays, but there is a clear pause between the two.
Thanks for that - I decided to go with the MediaPlayer method because you can set the background color to be clear, which means the still frame shows through while the video fades in/out. Oddly if I have my phone plugged in to XCode and Run the app it works great, but if I run the app on the phone with it untethered I get a moment of black between each run of the video (this is my first iPhone app by the way) - why would that be? Do I need to put a release version on my phone to make it play smoothly?
Cheers
Hey, I know it's been a long time, but did you ever figure this out?? I desperately, need to do the same thing. I have two different clips. Once one finished, the other plays, but there is a clear pause between the two.