1
我想設置的MPMoviePlayerController在MPMoviePlayerViewController的currentPlaybackTime財產,使其恢復播放從實時視頻(HLS流),當應用程序主動辭職它已停止。這裏是我的代碼:MPMoviePlayerViewController不能設置當前播放時間
//the functinon that sets playback time
- (void)setCurrentPlayTime:(NSNumber *)time {
if (self.moviePlayer.currentPlaybackTime < [time floatValue] - 10.0) {
[self.moviePlayer setCurrentPlaybackTime:(NSTimeInterval)[time floatValue]];
}
}
//app did become active callback
- (void) applicationDidBecomeActiveNotification:(NSNotification*)notification {
if (!isnan(_curPlayTime) && _curPlayTime > 0.0) {
[self performSelector:@selector(setCurrentPlayTime:) withObject:[NSNumber numberWithFloat:_curPlayTime] afterDelay:0.1];
}
}
//player load state did change callback
-(void)playerLoadStateDidChange:(NSNotification *)notification {
MPMoviePlayerController *player = notification.object;
MPMovieLoadState loadState = player.loadState;
if (loadState & MPMovieLoadStatePlaythroughOK) {
if (!isnan(_curPlayTime) && _curPlayTime > 0.0) {
[self performSelector:@selector(setCurrentPlayTime:) withObject:[NSNumber numberWithFloat:_curPlayTime] afterDelay:0.1];
_curPlayTime = 0.0;
}
}
當我只需輕按Home鍵,然後重新打開應用程序,並且如果我得到的來電,但拒絕它,它的工作原理。但是,如果我接聽電話,我完成了電話後,打從0.0忽略setCurrentPlaybackTime方法調用開始。有誰知道,問題在哪裏,並且可能是任何示例,應該怎樣做才能正確工作?
沒有發現currentPlayTime屬性或setCurrentPlayTime既不的MPMoviePlayerController接口也不在MPMediaPlayback協議。你能不能給一個鏈接文檔呢? – 2013-07-31 09:00:57
property currentPlaybackTime http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html 它的setter因此setCurrentPlaybackTime – Nuthinking 2013-08-01 10:11:53
所以它仍然是currentPlay * back * Time,而不是currentPlayTime 。 – 2013-08-07 12:31:57