开发者

iOS4 MPMoviePlayerController Embedding

I am using MPMoviePlayerController currently to play a video inside IPhone and now I wish to play this video in a small area of the view (not the full screen). I think there is a frame way of doing it but I couldn't find the required tutorial somewhere. Have you been across any? That would be great.

UPDATED


I have reached to this point but still it doesn't show the player to play on screen.

-(IBAction)startVideo {
    //start video here
    NSURL *path = [[NSURL alloc] i开发者_JAVA技巧nitWithString:[self localVideoPath:NO]];

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

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

    // May help to reduce latency
    [moviePlayer prepareToPlay];

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


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

    [image removeFromSuperview];

    [self.view addSubview:moviePlayer.view];

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

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


Here is 'windowed' code...

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
 initWithContentURL:[NSURL fileURLWithPath:url]];

[player setControlStyle:MPMovieControlStyleNone];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(movieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];
[player setScalingMode:MPMovieScalingModeAspectFill];
[player setFullscreen:FALSE];

//---play partial screen---
player.view.frame = CGRectMake(0, 0, 200, 300);
[self.view addSubview:player.view];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜