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

Commit 16c6698

Browse files
committed
[ASVideoNode] Add delegate method called when the currentItem is set.
1 parent 6dac29a commit 16c6698

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

AsyncDisplayKit/ASVideoNode.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ NS_ASSUME_NONNULL_BEGIN
121121
* @param videoNode The videoNode
122122
*/
123123
- (void)videoNodeDidFinishInitialLoading:(ASVideoNode *)videoNode;
124+
/**
125+
* @abstract Delegate method invoked when the AVPlayerItem for the asset has been set up and can be accessed throught currentItem.
126+
* @param videoNode The videoNode.
127+
* @param currentItem The AVPlayerItem that was constructed from the asset.
128+
*/
129+
- (void)videoNode:(ASVideoNode *)videoNode didSetCurrentItem:(AVPlayerItem *)currentItem;
124130
/**
125131
* @abstract Delegate method invoked when the video node has recovered from the stall
126132
* @param videoNode The videoNode

AsyncDisplayKit/ASVideoNode.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ @interface ASVideoNode ()
4646
unsigned int delegateVideoNodeDidPlayToTimeInterval:1;
4747
unsigned int delegateVideoNodeDidStartInitialLoading:1;
4848
unsigned int delegateVideoNodeDidFinishInitialLoading:1;
49+
unsigned int delegateVideoNodeDidSetCurrentItem:1;
4950
unsigned int delegateVideoNodeDidStallAtTimeInterval:1;
5051
unsigned int delegateVideoNodeDidRecoverFromStall:1;
5152

@@ -150,7 +151,11 @@ - (void)prepareToPlayAsset:(AVAsset *)asset withKeys:(NSArray<NSString *> *)requ
150151
} else {
151152
self.player = [AVPlayer playerWithPlayerItem:playerItem];
152153
}
153-
154+
155+
if (_delegateFlags.delegateVideoNodeDidSetCurrentItem) {
156+
[_delegate videoNode:self didSetCurrentItem:playerItem];
157+
}
158+
154159
if (self.image == nil) {
155160
[self generatePlaceholderImage];
156161
}
@@ -464,6 +469,7 @@ - (void)setDelegate:(id<ASVideoNodeDelegate>)delegate
464469
_delegateFlags.delegateVideoNodeDidPlayToTimeInterval = [_delegate respondsToSelector:@selector(videoNode:didPlayToTimeInterval:)];
465470
_delegateFlags.delegateVideoNodeDidStartInitialLoading = [_delegate respondsToSelector:@selector(videoNodeDidStartInitialLoading:)];
466471
_delegateFlags.delegateVideoNodeDidFinishInitialLoading = [_delegate respondsToSelector:@selector(videoNodeDidFinishInitialLoading:)];
472+
_delegateFlags.delegateVideoNodeDidSetCurrentItem = [_delegate respondsToSelector:@selector(videoNode:didSetCurrentItem:)];
467473
_delegateFlags.delegateVideoNodeDidStallAtTimeInterval = [_delegate respondsToSelector:@selector(videoNode:didStallAtTimeInterval:)];
468474
_delegateFlags.delegateVideoNodeDidRecoverFromStall = [_delegate respondsToSelector:@selector(videoNodeDidRecoverFromStall:)];
469475

0 commit comments

Comments
 (0)