views:

97

answers:

2

Hello,

The following code used to work but now it doesn't and I have not changed anything about it.

if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) {
        MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]]; 
        [self presentMoviePlayerViewControllerAnimated:moviePlayer];
        [moviePlayer release];
    }
    else {
        MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]] autorelease];
        [moviePlayer play];
    }

So if the OS supports the method presentMoviePlayerViewControllerAnimated we use this approach but if its OS < 3.2 we use the old method but this doesn't work anymore on my iPhone 1st gen OS 3.0.1 or iPod Touch 2nd gen OS 3.1.3. Nothing happens when the code is fired.

Hope you can help me.

Cheers

A: 

I guess you shall set the MPMoviePlayerController view frame to the CGRect you want to display it and then add this view as a subview before playing. Have a look at Apple Documentation

rano
Nope that does not work on 3.0+, the MPMoviePlayerController does not have a view.
objneodude
+1  A: 

Ahh its the autorelease part which is doing the wreckage.

From

        MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]] autorelease];
    [moviePlayer play];

to

        MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:selectedLink]];
    [moviePlayer play];

Cheers

objneodude