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 07-05-2010, 02:58 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 24
rmatakajr is on a distinguished road
Default 4.0 Movie code working but call back does not :(

Hey Guys having an issue here



I have this code working for the movie player on 4.0 OS


MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:escapedUrl]];
theMovie.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
[self.view addSubview:theMovie.view];
theMovie.controlStyle=MPMovieControlStyleFullscree n;

[theMovie play];


Im trying to stick in a notifier when the [done] button gets pressed


So i put in


//Register for the playback finished notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];


Before


[theMovie play];


Well when i press thedone button its suppost to call


-(void)myMovieFinishedCallbackNSNotification*)aNo tification
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
MPMoviePlayerController* theMovie=[aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie release];
[activityIndicator stopAnimating];
}


Well when i press done on the controller the movie dtops playing but the view does not close and return back tomy application

can someone help me figure this out please


Thank You

Ricky
rmatakajr is offline   Reply With Quote
Old 07-05-2010, 03:16 PM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

I don't see where you've added any code to close the view, so it just sits there. You probably want this line before you release:

Code:
[theMovie removeFromSuperview];
JasonR is offline   Reply With Quote
Old 07-05-2010, 03:24 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 24
rmatakajr is on a distinguished road
Default

Hey Thanks for your quick reply dude

Code:
		MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:escapedUrl]];
		theMovie.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
		[self.view addSubview:theMovie.view];
		theMovie.controlStyle=MPMovieControlStyleFullscreen;


		//Register for the playback finished notification. 
		[[NSNotificationCenter defaultCenter] addObserver:self 
											  selector:@selector(myMovieFinishedCallback:) 
											  name:MPMoviePlayerPlaybackDidFinishNotification 
											  object:theMovie];
Then I added what you told me

Code:
   [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
	MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
										  name:MPMoviePlayerPlaybackDidFinishNotification 
										  object:theMovie];
	[theMovie removeFromSuperview]; // <----------
    [theMovie release]; 
	[activityIndicator stopAnimating];
First thing that happens is the audio starts to play then there is a deley before the controls display

Then when i press the done button the movie freezes and not returned to app

Any Ideas

Ricky
rmatakajr is offline   Reply With Quote
Old 07-05-2010, 04:56 PM   #4 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

Did you ignore a warning? That code should not have compiled with the typo. It should be
Code:
[theMovie.view removeFromSuperview];
I can't help you with the audio problem, I've never seen that before.
JasonR is offline   Reply With Quote
Old 07-05-2010, 05:21 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 24
rmatakajr is on a distinguished road
Default

WOW im a smuck.. thanks!! i guess im just to into the code to see the small thing... he he thanks a million!!

One more question, i have working code for 3.1.1 how do i do an if else to
detect the OS version?

Im real new to the iphone code and i have been winging it

Thanks
Ricky
rmatakajr is offline   Reply With Quote
Old 07-05-2010, 07:50 PM   #6 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

The idea is to test for the functionality instead of the OS version whenever possible. Since 3.2 and 4.0 have the option of playing full screen or not, here's code that detects that to decide which way to go:

Code:
     moviePlayer = [[MPMoviePlayerController  alloc] initWithContentURL:movieURL];

     if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
          moviePlayer.shouldAutoplay = YES;
          [self.view addSubview:moviePlayer.view];
          [moviePlayer setFullscreen:YES animated:YES];
     }
     else {
          [moviePlayer play];
     }
JasonR is offline   Reply With Quote
Old 07-05-2010, 10:43 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 24
rmatakajr is on a distinguished road
Default

Awesome man! Thanks alot, im going to give that code a whirl tomorrow
really though thanks for all your help


Ricky
rmatakajr is offline   Reply With Quote
Old 12-08-2010, 08:23 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 4
rc20rd is on a distinguished road
Default thank you very much

That is great.
The done button works
thanks
rc20rd is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, movie

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: 333
7 members and 326 guests
anothermine, Chickenrig, givensur, iNet, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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