Кнопка MPMovieplayerController «Готово» - PullRequest
2 голосов
/ 28 апреля 2011

У меня проблема с 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 Ответ

1 голос
/ 28 апреля 2011

Поскольку указанное свойство называется controlStyle, вы можете использовать mp.controlStyle=..; или [mp setControlStyle:..];

По второму вопросу / проблеме см. mpmovieplayercontroller-audio-show-done-button для быстрого решения.

...