Skip to content

Commit cb1579e

Browse files
committed
Check the AVAsset's type before casting to an AVURLAsset
1 parent a3576d5 commit cb1579e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

AsyncDisplayKit/ASVideoNode.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,10 @@ - (void)setAsset:(AVAsset *)asset
277277
{
278278
ASDN::MutexLocker l(_videoLock);
279279

280-
if (ASObjectIsEqual(((AVURLAsset *)asset).URL, ((AVURLAsset *)_asset).URL)) {
280+
if (ASObjectIsEqual(asset, _asset)
281+
|| ([asset isKindOfClass:[AVURLAsset class]]
282+
&& [_asset isKindOfClass:[AVURLAsset class]]
283+
&& ASObjectIsEqual(((AVURLAsset *)asset).URL, ((AVURLAsset *)_asset).URL))) {
281284
return;
282285
}
283286

AsyncDisplayKitTests/ASVideoNodeTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@interface ASVideoNodeTests : XCTestCase
1414
{
1515
ASVideoNode *_videoNode;
16-
AVAsset *_firstAsset;
16+
AVURLAsset *_firstAsset;
1717
AVAsset *_secondAsset;
1818
}
1919
@end
@@ -43,7 +43,7 @@ @implementation ASVideoNodeTests
4343
- (void)setUp
4444
{
4545
_videoNode = [[ASVideoNode alloc] init];
46-
_firstAsset = [AVAsset assetWithURL:[NSURL URLWithString:@"firstURL"]];
46+
_firstAsset = [AVURLAsset assetWithURL:[NSURL URLWithString:@"firstURL"]];
4747
_secondAsset = [AVAsset assetWithURL:[NSURL URLWithString:@"secondURL"]];
4848
}
4949

@@ -67,7 +67,7 @@ - (void)testVideoNodeDoesNotReplaceAVPlayerItemWhenSameURLIsSet
6767
_videoNode.asset = _firstAsset;
6868
AVPlayerItem *item = [_videoNode currentItem];
6969

70-
_videoNode.asset = _firstAsset;
70+
_videoNode.asset = [AVAsset assetWithURL:_firstAsset.URL];
7171
AVPlayerItem *secondItem = [_videoNode currentItem];
7272

7373
XCTAssertEqualObjects(item, secondItem);

0 commit comments

Comments
 (0)