2011-08-31 15 views
8

Mam podklasę MPMoviePlayerController, która powinna pokazać kontrolki po zakończeniu odtwarzania. Mam załączeniu reagował na zgłoszenia MPMoviePlayerPlaybackDidFinishNotification i próbował ustawieniu stylu sterowania w następujący sposób:Programowo pokazane formanty w MPMoviePlayerController

[self setControlStyle:MPMovieControlStyleEmbedded]; 

To nie działa. Zasadniczo na końcu filmu chcę sterować, aby pokazać. Jak mogę wyświetlać kontrolki programowo?

UWAGA: Kontroler NIE jest w trybie pełnoekranowym.

+0

Czy jesteś pewien, że MPMoviePlayerPlaybackDidFinishNotification otrzymuje powiadomienie? Możesz ustawić punkt przerwania lub komunikat NSLog, aby się upewnić. –

+0

Czy kiedykolwiek wymyśliłeś rozwiązanie dla tego Roberta? – ToddH

+0

Obawiam się, że zbyt dawno temu pamiętam, ale myślę, że w końcu zmieniliśmy się na używanie innego gracza? –

Odpowiedz

0

Uprzejmie znaleźć pełny kod o tym, że działa ze mną

dodać .h class dodać ten

@property(strong,nonatomic) MPMoviePlayerViewController * moviePlayer; 

w klasie .m dodać ten kod "przekazać URL filmu"

-(void) playMovie:(NSString *)filePath 
{ 
    NSURL *theOutputURL = [NSURL fileURLWithPath:filePath]; 
    if(_moviePlayer) 
     [_moviePlayer.moviePlayer setContentURL:theOutputURL]; 
    else 
     _moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:theOutputURL]; 

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

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:_moviePlayer.moviePlayer]; 

    if (![_moviePlayer.moviePlayer isPreparedToPlay]) 
     [_moviePlayer.moviePlayer prepareToPlay]; 

    _moviePlayer.moviePlayer.movieSourceType = MPMovieSourceTypeFile; 
    [_moviePlayer.moviePlayer setFullscreen:YES]; 
    _moviePlayer.moviePlayer.controlStyle=MPMovieControlStyleEmbedded; 
    [_moviePlayer.moviePlayer setContentURL:theOutputURL]; 
    _moviePlayer.view.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height); 
    [_moviePlayer shouldAutorotateToInterfaceOrientation: AVCaptureVideoOrientationLandscapeRight]; 
    [self.view addSubview:_moviePlayer.view]; 
} 


- (void) moviePlayerPlaybackStateDidChange: (NSNotification *) notification { 
    if (_moviePlayer.moviePlayer.playbackState == MPMoviePlaybackStateStopped) { 
     [_moviePlayer.moviePlayer setContentURL:[_moviePlayer.moviePlayer contentURL]]; 
     [_moviePlayer.moviePlayer play]; 
    } 
} 

-(void)myMovieFinishedCallback:(NSNotification*)aNotification 
{ 
    // to add your code after playback is finished 

} 
Powiązane problemy