开发者

IPhone Frame Video Playing

I have written this piece of objective-c code for playing a video after touching an image.

    //start video here
    NSString *path = [self loca开发者_开发技巧lVideoPath:NO];

    // Create custom movie player   
    MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithPath:path] autorelease];

    [moviePlayer setControlStyle:MPMovieControlStyleNone];

    [[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(onMSAASDone:)
        name:MPMoviePlayerPlaybackDidFinishNotification
        object:moviePlayer];

    [moviePlayer setScalingMode:MPMovieScalingModeAspectFill];
    [moviePlayer setFullscreen:FALSE];

    //---play partial screen---
    moviePlayer.view.frame = CGRectMake(0, 0, 200, 300);
    //[[moviePlayer view] setFrame: [image bounds]];

    [self.view addSubview:moviePlayer.view];

    // Show the movie player as modal
    //[self presentModalViewController:moviePlayer animated:YES];

    // Prep and play the movie
    [moviePlayer play];

The problem is that the code stops working at second line of statement. The error is... Program GDB: Received Signal: "EXC_BAD_ACCESS"

Help Me Please!


 MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithPath:path] autorelease];

the function initWithPath is not the part of MPMoviePlayerController class, i could not find it in documentation. May be you were trying to use

- (id)initWithContentURL:(NSURL *)url

plz read the apple documentation.

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜