Check the AVAsset's type before casting to an AVURLAsset

This commit is contained in:
Eric Jensen 2016-02-26 11:00:27 -08:00
parent a3576d5d61
commit cb1579e8af
2 changed files with 7 additions and 4 deletions

View File

@ -277,7 +277,10 @@
{ {
ASDN::MutexLocker l(_videoLock); ASDN::MutexLocker l(_videoLock);
if (ASObjectIsEqual(((AVURLAsset *)asset).URL, ((AVURLAsset *)_asset).URL)) { if (ASObjectIsEqual(asset, _asset)
|| ([asset isKindOfClass:[AVURLAsset class]]
&& [_asset isKindOfClass:[AVURLAsset class]]
&& ASObjectIsEqual(((AVURLAsset *)asset).URL, ((AVURLAsset *)_asset).URL))) {
return; return;
} }

View File

@ -13,7 +13,7 @@
@interface ASVideoNodeTests : XCTestCase @interface ASVideoNodeTests : XCTestCase
{ {
ASVideoNode *_videoNode; ASVideoNode *_videoNode;
AVAsset *_firstAsset; AVURLAsset *_firstAsset;
AVAsset *_secondAsset; AVAsset *_secondAsset;
} }
@end @end
@ -43,7 +43,7 @@
- (void)setUp - (void)setUp
{ {
_videoNode = [[ASVideoNode alloc] init]; _videoNode = [[ASVideoNode alloc] init];
_firstAsset = [AVAsset assetWithURL:[NSURL URLWithString:@"firstURL"]]; _firstAsset = [AVURLAsset assetWithURL:[NSURL URLWithString:@"firstURL"]];
_secondAsset = [AVAsset assetWithURL:[NSURL URLWithString:@"secondURL"]]; _secondAsset = [AVAsset assetWithURL:[NSURL URLWithString:@"secondURL"]];
} }
@ -67,7 +67,7 @@
_videoNode.asset = _firstAsset; _videoNode.asset = _firstAsset;
AVPlayerItem *item = [_videoNode currentItem]; AVPlayerItem *item = [_videoNode currentItem];
_videoNode.asset = _firstAsset; _videoNode.asset = [AVAsset assetWithURL:_firstAsset.URL];
AVPlayerItem *secondItem = [_videoNode currentItem]; AVPlayerItem *secondItem = [_videoNode currentItem];
XCTAssertEqualObjects(item, secondItem); XCTAssertEqualObjects(item, secondItem);