gpt4 book ai didi

iOS > 可以播放部分下载的视频吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:25:06 25 4
gpt4 key购买 nike

假设我们正在下载一个大视频 - 它有 50Mb - 但到目前为止只下载了 25Mb - 是否可以在完全下载之前开始播放视频?

最佳答案

我假设您正在为您的视频使用 MPMoviePlayerController...

MPMoviePlayerController 有一个 loadState 属性,你可以用 this notification 监控它.检查视频是否已下载到可播放的范围,然后播放。

//Begin observing the moviePlayer's load state.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer];


- (void)moviePlayerLoadStateChanged:(NSNotification *)notification{
//NSLog(@"State changed to: %d\n", moviePlayer.loadState);
if(moviePlayer.loadState == MPMovieLoadStatePlayable && [videoIndicator isAnimating]){
//if load state is ready to play
[videoIndicator stopAnimating];//Pause and hide the indicator
[self.contentView addSubview:[moviePlayer view]];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer play];//play the video
}

}

这非常重要:如果您尝试下载超过 10 十分钟的视频,您将需要使用 HTTP Live Streaming .

关于iOS > 可以播放部分下载的视频吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11305785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com