Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS multiple views and MPMoviePlayer issue
    text
    copied!<p>I have two view controllers, one is mainController second one is movieController...</p> <p>After swiping back to mainController from movieController with <code>[self.view removeFromSuperview];</code> video playing in movieController still plays as background sound.</p> <p>I did release player, but no idea.</p> <pre><code>@synthesize viewForMovie,player; - (void)viewDidLoad { [super viewDidLoad]; //background image self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"mits_bg.png"]]; //gesture recognizer -to up UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)]; swipeGesture.direction = UISwipeGestureRecognizerDirectionDown; [self.view addGestureRecognizer:swipeGesture]; [swipeGesture release]; //movie player [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDurationAvailable:) name:MPMovieDurationAvailableNotification object:nil]; **self.player = [[[MPMoviePlayerController alloc] init] autorelease];** //self.player.controlStyle = MPMovieControlStyleNone; // no control at all :) self.player.contentURL = [self movieURL]; self.player.view.frame = self.viewForMovie.bounds; self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ; [self.viewForMovie addSubview:player.view]; [self.player play]; } //---gesture recognizer - (IBAction) handleSwipes:(UIGestureRecognizer *) sender { UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *) sender direction]; if (direction == UISwipeGestureRecognizerDirectionDown) { CATransition *transition = [CATransition animation]; transition.duration = 0.75; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromBottom; transition.delegate = self; // Next add it to the containerView's layer. This will perform the transition based on how we change its contents. [self.view.superview.layer addAnimation:transition forKey:nil]; [self.view removeFromSuperview]; **self.player = nil;** //[player release]; // I give it a try like this also } } - (void)viewDidUnload { [super viewDidUnload]; self.viewForMovie = nil; self.player = nil; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [thumbnailScrollView release]; [viewForMovie release]; [onScreenDisplayLabel release]; [player release]; [super dealloc]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload