Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 3761d8b

Browse files
nguyenhuyAdlai Holler
authored andcommitted
ASVideoNode should play when its player is ready and if it is expected to play (#2876)
- When a video node is first visible, it's player is called to play if auto play flag is on. However, the player might not be ready by that time, especially when the video is loaded on a slow network. The player just continues loading its asset. - When the player is ready, we should check if it is expected to be playing and if true, try to play again.
1 parent 202c947 commit 3761d8b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

AsyncDisplayKit/ASVideoNode.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
314314
if ([change[NSKeyValueChangeNewKey] integerValue] == AVPlayerItemStatusReadyToPlay) {
315315
if (self.playerState != ASVideoNodePlayerStatePlaying) {
316316
self.playerState = ASVideoNodePlayerStateReadyToPlay;
317+
if (_shouldBePlaying && ASInterfaceStateIncludesVisible(self.interfaceState)) {
318+
[self play];
319+
}
317320
}
318321
// If we don't yet have a placeholder image update it now that we should have data available for it
319322
if (self.image == nil && self.URL == nil) {

0 commit comments

Comments
 (0)