Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-25-2009, 08:28 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 5
pr0fess0r is on a distinguished road
Thumbs down Seamless looping video issue

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?

Cheers
pr0fess0r is offline   Reply With Quote
Old 01-25-2009, 10:53 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

avoid imageNamed, try imageWithContentsOfFile instead
lbendlin is offline   Reply With Quote
Old 01-25-2009, 11:35 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 5
pr0fess0r is on a distinguished road
Default

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
pr0fess0r is offline   Reply With Quote
Old 07-13-2009, 05:31 AM   #4 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 1
ybetzer is on a distinguished road
Default Video flickering

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 View Post
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
ybetzer is offline   Reply With Quote
Old 09-02-2009, 02:01 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 5
Brianu is on a distinguished road
Default flickering video replay here too

Quote:
Originally Posted by ybetzer View Post
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 ?
Mine doesn't seem to double each time.

thanks for any helpings!
Brianu is offline   Reply With Quote
Old 06-30-2010, 06:47 PM   #6 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 39
johnhmeyer123 is on a distinguished road
Default

Quote:
Originally Posted by pr0fess0r View Post
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.
johnhmeyer123 is offline   Reply With Quote
Old 06-30-2010, 06:56 PM   #7 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 39
johnhmeyer123 is on a distinguished road
Default

Quote:
Originally Posted by pr0fess0r View Post
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.
johnhmeyer123 is offline   Reply With Quote
Old 07-11-2011, 08:41 AM   #8 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 7
Elsammak is on a distinguished road
Default

PLZ help..did any one got it????
Elsammak is offline   Reply With Quote
Old 09-11-2011, 08:48 PM   #9 (permalink)
App Developer
 
mongoose250's Avatar
 
Join Date: Dec 2008
Location: Indiana
Posts: 25
mongoose250 is on a distinguished road
Send a message via ICQ to mongoose250 Send a message via AIM to mongoose250
Default

myMoviePlayer.repeatMode = MPMovieRepeatModeOne; /// LOOPS MOVIE FOREVER
mongoose250 is offline   Reply With Quote
Old 03-27-2012, 12:20 PM   #10 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 2
charlesmwray is on a distinguished road
Default Update

To get it to loop forever I used the following code:

Code:
playercontroller.moviePlayer.repeatMode = MPMovieRepeatModeOne;
Where
Code:
playercontroller
is the name of my MPMoviePlayerViewController. The rest is just part of the class.
charlesmwray is offline   Reply With Quote
Reply

Bookmarks

Tags
looping, seamless, video

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 387
10 members and 377 guests
chits12345, ChrisYates, fiftysixty, fredidf, gmarro, KennyChong, Leslie80, Meoz, ryantcb, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:28 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0