提交 3797b19d 编写于 作者: Z zhangxinzheng 提交者: xinzhengzhang

ios/IJKAVMoviePlayer add once token for ready to play status

上级 33f85005
......@@ -122,7 +122,7 @@ static void *KVO_AVPlayerItem_playbackBufferEmpty = &KVO_AVPlayerItem_play
IJKKVOController *_playerItemKVO;
id _timeObserver;
dispatch_once_t _readyToPlayToken;
// while AVPlayer is prerolling, it could resume itself.
// foring start could
BOOL _isPrerolling;
......@@ -726,22 +726,24 @@ static IJKAVMoviePlayerController* instance;
/* Once the AVPlayerItem becomes ready to play, i.e.
[playerItem status] == AVPlayerItemStatusReadyToPlay,
its duration can be fetched from the item. */
[_avView setPlayer:_player];
self.isPreparedToPlay = YES;
AVPlayerItem *playerItem = (AVPlayerItem *)object;
NSTimeInterval duration = CMTimeGetSeconds(playerItem.duration);
if (duration <= 0)
self.duration = 0.0f;
else
self.duration = duration;
[[NSNotificationCenter defaultCenter]
postNotificationName:IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:self];
if (_shouldAutoplay)
[_player play];
dispatch_once(&_readyToPlayToken, ^{
[_avView setPlayer:_player];
self.isPreparedToPlay = YES;
AVPlayerItem *playerItem = (AVPlayerItem *)object;
NSTimeInterval duration = CMTimeGetSeconds(playerItem.duration);
if (duration <= 0)
self.duration = 0.0f;
else
self.duration = duration;
[[NSNotificationCenter defaultCenter]
postNotificationName:IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:self];
if (_shouldAutoplay)
[_player play];
});
}
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册