50Mb の大きなビデオをダウンロードしているとしますが、これまでにダウンロードしたのは 25Mb だけです。ダウンロードが完了する前にビデオの再生を開始することはできますか?
1 に答える
1
ビデオにMPMoviePlayerControllerを使用していると仮定します...
MPMoviePlayerControllerには、この通知で監視できるloadStateプロパティがあります。ビデオが再生可能な範囲でダウンロードされているかどうかを確認してから、再生します。
//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ライブストリーミングを使用する必要があります。
于 2012-07-03T13:53:16.070 に答える