2012-01-24 74 views
0

我想知道用戶關閉視頻時視頻進展的程度。如何從MPMoviePlayerController獲取播放%進度

所以對我有這樣的:

- (void) moviePlayerDidFinsh:(NSNotification*) notification 
{ 
    MPMoviePlayerController* moviePlayer = notification.object; 
    NSLog(@"FINISHED duration was:%f", moviePlayer.duration); 
} 

initialPlaybackTimeendPlaybackTime都縫是無用的。

回答

3

MPMediaPlayback協議中有一個屬性currentPlaybackTime

播放頭的當前位置。 (必需)

@屬性(非原子)NSTimeInterval currentPlaybackTime

%值= currentPlaybackTime /持續時間;

+0

謝謝,不知道我是如何錯過的... – Robert

1

該物業是currentPlaybackTime(以秒爲單位)。

這隻有在MPMovieFinishReason等於MPMovieFinishReasonUserExited時纔有用。

NSDictionary* userInfo = [aNotification userInfo];  
MPMovieFinishReason finishReason = [[userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; 
if (finishReason == MPMovieFinishReasonUserExited) { 
     NSTimeInterval playbackTime = [moviePlayer currentPlaybackTime]; 
     // ... 
} 
+0

不,不是。我試過'MPMovieFinishReasonPlaybackEnded'。它也有效。 – z33

相關問題