我正在缓存一个m3u8格式的视频,我将此网址设置为MPMovieplayerController的内容
我正在运行一个每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];
}
问题在于,如果我按下主页按钮然后返回应用程序,缓冲时间将丢失,即数据必须再次缓冲。 无论如何都要克服这个问题..?
答案 0 :(得分:0)
这在设计上并没有任何改变。