0

我正在缓冲 m3u8 格式的视频,我将此 url 设置为 MPMovieplayerController 的 contenturl

我正在运行一个每 0.3 秒运行一次的后台线程,我用它来检查缓冲和播放的持续时间并相应地执行检查

if(!mPlaybackProgressTimer)
    mPlaybackProgressTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(didPlayback:) userInfo:nil repeats:YES] retain];

在 didplayback 中

..

- (void)didPlayback:(id)sender {

    NSTimeInterval totalDuration = [mVideoPlayerController duration];

    NSTimeInterval playbackTime = [mVideoPlayerController currentPlaybackTime];
    float playbackProgress = 0.0;

   if(playbackTime > 0.0 && totalDuration > 0.0)
       playbackProgress = playbackTime / totalDuration;

   mPercentWatched = round(100 * playbackProgress);

   NSTimeInterval bufferedTime = [mVideoPlayerController playableDuration];
   float bufferProgress = 0.0;

   if(playbackTime > 0.0 && totalDuration > 0.0)
       bufferProgress = bufferedTime / totalDuration;

   [self setProgress:bufferProgress forProgressType:eProgressTypeBuffer];
   [self setProgress:playbackProgress forProgressType:eProgressTypePlay];
}

问题是,如果我按下主页按钮然后回到应用程序,缓冲时间将丢失,即数据必须再次缓冲..有没有办法克服这个问题..?

4

1 回答 1

0

这是设计使然,无论如何都不能改变。

于 2013-01-09T14:26:45.250 回答