开发者

iPhone OS 3.0 playing movies wont work

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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜