Ok finally make my app to have setContentURL method. But now it’s break my app, and I am so close to the end 🙁
This is where code breaks:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// please work!!!
NSString *title = [[NSString alloc] initWithFormat:@"bla bla"];
NSURL *newURL = [NSURL URLWithString:title];
[mp setContentURL:newURL];
}
This is method that is started when app is first time loaded, and it loads movie fine, problem in in call to setContentURL because thet is the point where my app crash:
- (void) readyPlayer
{
mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if ([mp respondsToSelector:@selector(loadState)])
{
// Set movie player layout
//[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setControlStyle:MPMovieControlStyleNone];
[mp setFullscreen:YES];
// May help to reduce latency
[mp prepareToPlay];
// Register that the load state changed (movie is ready)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerLoadStateChanged:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
else
{
// Register to receive a notification when the movie is in memory and ready to play.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:nil];
}
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
}
You allocate memory by performing [… alloc] but i don’t see any autoreleases or releases… This might be the reason that the app crashes because ObjC doesn’t have a garbage collector and you need to clean up yourself. If memory gets to high, your app will terminate.