2015-07-01 9 views
15

Dopo aver impostato la proprietà initialPlaybackTime, il video (streaming HTTP) viene riprodotto dall'inizio.Proprietà MPMoviePlayerController initialPlaybackTime non funziona in iOS 8.4

Lo stesso codice funziona bene in iOS < = 8.3:

self.moviePlayer.initialPlaybackTime = self.lastPlaybackTime; 
[self.moviePlayer play]; 
+3

Anche io sto affrontando lo stesso problema, così come non tutti i tipi di file possono essere riprodotti ora. Inoltre, ecco un radar http://www.openradar.me/20762442 con problemi in quel componente. Sembra che Apple abbia rotto il mpmoviewplayer deprecato in quella versione e tu debba passare a AVKit –

+0

setCurrenPlaybackTime sembra anche essere rotto. – JDL

+0

Ci ho giocato per un paio d'ore senza alcuna fortuna, sembra che la risposta generale della community sia che al momento è rotta. –

risposta

6

Questo funziona per me, in fondo è necessario setCurrentPlaybackTime quando il film inizia a suonare, ma è anche necessario una bandiera playbackDurationSet che è impostato su NO quando si presenta movieplayer ed è impostato su YES quando il film viene cercato per la prima volta in playbackDuration.

NOTA: è richiesto questo flag, perché quando si cerca il filmato dal scrubber cercare la moviePlayerPlaybackStateChanged viene licenziato con playbackState di MPMoviePlaybackStatePlaying.

BOOL playbackDurationSet = NO; 
- (void)moviePlayerPlaybackStateChanged:(NSNotification*)notification 
{ 
    MPMoviePlayerController* player = (MPMoviePlayerController*)notification.object; 
    switch (player.playbackState) { 
     case MPMoviePlaybackStatePlaying: 
     if(!playbackDurationSet){ 
      [self.moviePlayer setCurrentPlaybackTime:yourStartTime]; 
      playbackDurationSet = YES; 
     } 
     break; 
    } 
} 

- (void)moviePlayerPresented 
{ 
     playbackDurationSet = NO; 
} 
0

Ho visto alcuni di questi problemi pure. Poiché MPMoviePlayerController è obsoleto in iOS 9, è improbabile che vengano riparati.

0

risposta hariszaman ha funzionato per me:

- (void)moviePlaybackStateChanged:(NSNotification*)notif 
{ 
    //... 
    if (self.videoPlayer.playbackState == MPMoviePlaybackStatePlaying) { 

     if (self.currentBookmark) { 
      if ([[PSDeviceInfo sharedInstance] is_iOSatLeast84]){ 
       NSTimeInterval toTime = [self.currentBookmark.seconds doubleValue]; 
       [self.videoPlayer setCurrentPlaybackTime:toTime]; 
       self.currentBookmark = nil; 
      } 
     } 
    } 

if (self.videoPlayer.playbackState == MPMoviePlaybackStatePaused) { 
    //... 
} 

if (self.videoPlayer.playbackState == MPMoviePlaybackStateStopped) { 
    //... 
} 
} 

anche:

- (void)configureMoviePlayer 
    { 
     if (self.currentBookmark) { 
      if ([[PSDeviceInfo sharedInstance] is_iOSatLeast84]){ 
       // will set start after did start 
      }else { 
       NSTimeInterval toTime = [self.currentBookmark.seconds doubleValue]; 
       self.videoPlayer.initialPlaybackTime = toTime;    
       self.currentBookmark = nil; 
      } 
     } 
     else { 
      self.videoPlayer.initialPlaybackTime = 0; 
     } 
     //... 
    } 

il metodo is_iOSatLeast84:

- (BOOL)is_iOSatLeast84 
{ 
    // version 8.4 
    NSString *version = [[UIDevice currentDevice] systemVersion]; 
    BOOL isAtLeast84 = [version floatValue] >= 8.35; 

    return isAtLeast84; 
} 

Anche se tutto questo è una soluzione, si ottiene il lavoro fatto .