2011-07-22 96 views
0

我遇到了很多MPMoviePlayerController问题。我在使用iPhone/ipad中的MPMoviePlayerController时遇到问题

当我将视频从正常切换到全屏时,会出现一个条。在那里有前进/后退播放/暂停的按钮,但是按照我的要求,这些按钮不能正常工作,即单击前进/后退按钮不会改变下一个/上一个视频; MPMoviePlayerController停止其点击...

在此先感谢。

回答

0

尝试注册通知。

MPMoviePlaybackState 
Constants describing the current playback state of the movie player. 

enum { 
    MPMoviePlaybackStateStopped, 
    MPMoviePlaybackStatePlaying, 
    MPMoviePlaybackStatePaused, 
    MPMoviePlaybackStateInterrupted, 
    MPMoviePlaybackStateSeekingForward, 
    MPMoviePlaybackStateSeekingBackward 
}; 
typedef NSInteger MPMoviePlaybackState; 
0

做这样

-(void)videoClick:(id)sender 
{ 
    bi3.enabled=NO; 
    videoTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)]; 
    videoTable.dataSource = self; 
    videoTable.delegate = self; 
    videoTable.rowHeight=100; 
    videoTable.separatorStyle=UITableViewCellSeparatorStyleSingleLine; 
    videoTable.separatorColor=[UIColor brownColor]; 
    navTitleLabel.text = [NSString stringWithFormat:@"xxx"]; 
    [webView addSubview:videoTable]; 

} 

-(void)videoFile:(NSString *)moviepath 
{ 

    //[tools setHidden:YES]; 
// bi3.enabled=NO; 

    // Register to receive a notification when the movie scaling mode has changed. 


    //NSString *moviePath = [bundle pathForResource:@"video" ofType:@"mp4"]; 
    NSURL *movieURL1 = [[NSURL fileURLWithPath:moviepath] retain]; 
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL1]; 
    [theMovie setControlStyle:MPMovieControlStyleFullscreen]; 
    [theMovie play]; 
    MPMoviePlayerViewController *moviePlayer11 = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL1]; 
    [self presentMoviePlayerViewControllerAnimated:moviePlayer11]; // Override point for customization after app launch  
    // [navigationController.view addSubview:]; 
    //[self.view addSubview:mpMCtr.view]; 



} 
- (void) movieFinishedCallback:(NSNotification*) aNotification { 
    bi3.enabled=YES; 
    [tools setHidden:NO]; 
    MPMoviePlayerController *player = [aNotification object]; 
    [[NSNotificationCenter defaultCenter] 
    removeObserver:self 
    name:MPMoviePlayerPlaybackDidFinishNotification 
    object:player]; 
    // [player stop]; 
    //[self.view removeFromSuperview]; 
[player.view removeFromSuperview]; 

     [player autorelease];  
} 

- (void) moviePlayBackDidFinish:(NSNotification*)aNotification 
{ 

    MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                name:MPMoviePlayerPlaybackDidFinishNotification 
                object:theMovie]; 
    //[mpMCtr stop]; 

    [theMovie.view removeFromSuperview]; 
    [videoTable removeFromSuperview]; 

} 
-(void)backview:(id)sender 
{ 
    [mpMCtr stop]; 
    [mpMCtr.view removeFromSuperview]; 
    [videoTable removeFromSuperview]; 
    [self.navigationController popViewControllerAnimated:YES]; 
}