使用MPMoviePlayerController时遇到问题

时间:2011-07-22 09:55:23

标签: objective-c iphone ipad mpmovieplayercontroller

我在使用MPMoviePlayerController时面临很多问题。

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

2 个答案:

答案 0 :(得分:0)

尝试注册通知。

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

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

答案 1 :(得分: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];
}