Fork me on GitHub

记住用户上次播放的位置,然后下次播放时从历史时刻开始

记住用户上次播放的位置,然后下次播放时从历史时刻开始... 

获取 MPMovieDurationAvailableNotification 这个消息后 修改播放的位置

1。
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(durationAvailable:) 
                                                 name:MPMovieDurationAvailableNotification 
                                               object:nil];

2。
- (void) durationAvailable:(NSNotification*)notification 
{
    NSLog(@"durationAvailable notification ------ ");
    //[[NSNotificationCenter     defaultCenter]removeObserver:self name:MPMovieDurationAvailableNotification  object:nil];
    
    NSTimeInterval dur = moviePlayer.duration;
    NSLog(@"duration:%f",dur);
    
    if (playTime > 0.0 && playTime < dur) {
        moviePlayer.currentPlaybackTime = playTime;
    }
}

posted on 2012-03-26 15:18  pengyingh  阅读(461)  评论(0)    收藏  举报

导航