MPMovieplayerController“完成”按钮

时间:2011-04-28 10:40:03

标签: iphone ios4 mpmovieplayercontroller

我遇到了MPMovieplayerController的问题。

mp =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

现在当我尝试编写mp.时,列表中不包含“setControlStyle”!有什么不对吗?

如果我直接写[mp setControlStyle:MPMovieControlStyleFullscreen];而不是视频以全屏方式启动但是没有显示完成按钮但是如果我点击完成按钮的位置应该比它工作正常!!!

已编辑:

  - (id)initWithPath:(NSString *)moviePath
   {
// Initialize and create movie URL
    if (self = [super init])
   {
        movieURL = [NSURL URLWithString:moviePath];    
    [movieURL retain];
   }
return self;
 }

- (void) readyPlayer
{
mp =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

[mp setControlStyle:MPMovieControlStyleFullscreen];
 [mp setFullscreen:YES];

if ([mp respondsToSelector:@selector(loadState)]) 
{
    // Register that the load state changed (movie is ready)
[[NSNotificationCenter defaultCenter] addObserver:self 
                   selector:@selector(moviePlayerLoadStateChanged:) 
                   name:MPMoviePlayerLoadStateDidChangeNotification 
                   object:nil];
  }

  else

  {
  [NSNotificationCenter defaultCenter] addObserver:self 
                     selector:@selector(moviePreloadDidFinish:) 
                     name:MPMoviePlayerContentPreloadDidFinishNotification 
                     object:nil];
  }

  // Register to receive a notification when the movie has finished playing. 
 [[NSNotificationCenter defaultCenter] addObserver:self 
                    selector:@selector(moviePlayBackDidFinish:) 
                    name:MPMoviePlayerPlaybackDidFinishNotification 
                    object:nil];
 }

  - (void) loadView
  {
  [self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]  autorelease]];
[[self view] setBackgroundColor:[UIColor blackColor]];
  }

  - (void) moviePlayerLoadStateChanged:(NSNotification*)notification 
  {
//[self makeButton];
// Unless state is unknown, start playback
if ([mp loadState] != MPMovieLoadStateUnknown)
  {

    [[NSNotificationCenter  defaultCenter] removeObserver:self
                                       name:MPMoviePlayerLoadStateDidChangeNotification 
                                       object:nil];


   [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

    // Rotate the view for landscape playback
 [[self view] setBounds:CGRectMake(0, 0, 480, 320)];
 [[self view] setCenter:CGPointMake(160, 240)];
 [[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 

    // Set frame of movieplayer
    [[mp view] setFrame:CGRectMake(0, 0, 480, 320)];


// Add movie player as subview
  [[self view] addSubview:[mp view]];   

    // Play the movie
    [mp play];
}
 }

需要指导。

1 个答案:

答案 0 :(得分:1)

由于有问题的财产被称为controlStyle,您可以使用mp.controlStyle=..;[mp setControlStyle:..];

对于第二个问题,请参阅mpmovieplayercontroller-audio-show-done-button以获取快速解决方案。