[ASVideoNode] issue #1782 Placeholder images are replaced by a blank placeholder. Now checks the .URL property of the parent class as well as the .image to ensure that new placeholders aren't generated.

This commit is contained in:
Gareth Reese 2016-06-21 07:51:58 +01:00
parent e55037354c
commit 062bcf3631
2 changed files with 29 additions and 3 deletions

View File

@ -151,7 +151,7 @@ static NSString * const kStatus = @"status";
self.player = [AVPlayer playerWithPlayerItem:playerItem];
}
if (self.image == nil) {
if (self.image == nil && self.URL == nil) {
[self generatePlaceholderImage];
}
@ -284,7 +284,7 @@ static NSString * const kStatus = @"status";
if ([change[NSKeyValueChangeNewKey] integerValue] == AVPlayerItemStatusReadyToPlay) {
self.playerState = ASVideoNodePlayerStateReadyToPlay;
// If we don't yet have a placeholder image update it now that we should have data available for it
if (self.image == nil) {
if (self.image == nil && self.URL == nil) {
[self generatePlaceholderImage];
}
}

View File

@ -46,6 +46,9 @@
ASVideoNode *simonVideoNode = self.simonVideoNode;
[_rootNode addSubnode:simonVideoNode];
ASVideoNode *hlsVideoNode = self.hlsVideoNode;
[_rootNode addSubnode:hlsVideoNode];
_rootNode.layoutSpecBlock = ^ASLayoutSpec *(ASDisplayNode * _Nonnull node, ASSizeRange constrainedSize) {
guitarVideoNode.layoutPosition = CGPointMake(0, 0);
guitarVideoNode.preferredFrameSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height/3);
@ -55,8 +58,13 @@
simonVideoNode.layoutPosition = CGPointMake(0, [UIScreen mainScreen].bounds.size.height - ([UIScreen mainScreen].bounds.size.height/3));
simonVideoNode.preferredFrameSize = CGSizeMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/3);
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[guitarVideoNode, nicCageVideoNode, simonVideoNode]];
hlsVideoNode.layoutPosition = CGPointMake(0, [UIScreen mainScreen].bounds.size.height/3);
hlsVideoNode.preferredFrameSize = CGSizeMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/3);
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[guitarVideoNode, nicCageVideoNode, simonVideoNode, hlsVideoNode]];
};
[self.view addSubnode:_rootNode];
}
@ -117,6 +125,24 @@
return simonVideoNode;
}
- (ASVideoNode *)hlsVideoNode;
{
ASVideoNode *hlsVideoNode = [[ASVideoNode alloc] init];
hlsVideoNode.delegate = self;
hlsVideoNode.asset = [AVAsset assetWithURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"]];
hlsVideoNode.gravity = AVLayerVideoGravityResize;
hlsVideoNode.backgroundColor = [UIColor lightGrayColor];
hlsVideoNode.shouldAutorepeat = YES;
hlsVideoNode.shouldAutoplay = YES;
hlsVideoNode.muted = YES;
// Placeholder image
hlsVideoNode.URL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/en/5/52/Testcard_F.jpg"];
return hlsVideoNode;
}
- (ASButtonNode *)playButton;
{
ASButtonNode *playButtonNode = [[ASButtonNode alloc] init];