diff options
-rw-r--r-- | macosx/HBAVPlayer.m | 10 | ||||
-rw-r--r-- | macosx/HBPicture+UIAdditions.h | 2 | ||||
-rw-r--r-- | macosx/HBPicture+UIAdditions.m | 32 | ||||
-rw-r--r-- | macosx/HBPicture.m | 42 |
4 files changed, 47 insertions, 39 deletions
diff --git a/macosx/HBAVPlayer.m b/macosx/HBAVPlayer.m index d1028a2bb..d0b064a61 100644 --- a/macosx/HBAVPlayer.m +++ b/macosx/HBAVPlayer.m @@ -98,14 +98,12 @@ typedef void (^HBPlayableObverser)(void); if ([asset statusOfValueForKey:key error:&error] == AVKeyValueStatusFailed) { self.playable = NO; - self.loaded = YES; return; } if (!asset.isPlayable) { self.playable = NO; - self.loaded = YES; return; } @@ -131,6 +129,12 @@ typedef void (^HBPlayableObverser)(void); [self.playableObservers removeAllObjects]; } +- (void)setPlayable:(BOOL)playable +{ + _playable = playable; + self.loaded = YES; +} + - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (context == HBAVPlayerItemStatusContext) @@ -142,11 +146,9 @@ typedef void (^HBPlayableObverser)(void); break; case AVPlayerItemStatusReadyToPlay: self.playable = YES; - self.loaded = YES; break; case AVPlayerItemStatusFailed: self.playable = NO; - self.loaded = YES; break; } diff --git a/macosx/HBPicture+UIAdditions.h b/macosx/HBPicture+UIAdditions.h index fffe3d9b7..c13706146 100644 --- a/macosx/HBPicture+UIAdditions.h +++ b/macosx/HBPicture+UIAdditions.h @@ -25,7 +25,7 @@ @property (nonatomic, readonly, getter=isWidthEditable) BOOL widthEditable; @property (nonatomic, readonly, getter=isHeightEditable) BOOL heightEditable; -@property (nonatomic, readonly, getter=isKeepDisplayAspect) BOOL keepDisplayAspectEditable; +@property (nonatomic, readonly, getter=isKeepDisplayAspectEditable) BOOL keepDisplayAspectEditable; @property (nonatomic, readonly, getter=isCustomAnamorphicEnabled) BOOL customAnamorphicEnabled; @end diff --git a/macosx/HBPicture+UIAdditions.m b/macosx/HBPicture+UIAdditions.m index 87759ad74..81da8c986 100644 --- a/macosx/HBPicture+UIAdditions.m +++ b/macosx/HBPicture+UIAdditions.m @@ -16,20 +16,33 @@ @dynamic maxHorizontalCrop; @dynamic maxVerticalCrop; -@dynamic keepDisplayAspectEditable; - #pragma mark - Editable state ++ (NSSet<NSString *> *)keyPathsForValuesAffectingWidthEditable +{ + return [NSSet setWithObjects:@"anamorphicMode", nil]; +} + - (BOOL)isWidthEditable { return (self.anamorphicMode != HB_ANAMORPHIC_STRICT) ? YES : NO; } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingHeightEditable +{ + return [NSSet setWithObjects:@"anamorphicMode", nil]; +} + - (BOOL)isHeightEditable { return (self.anamorphicMode != HB_ANAMORPHIC_STRICT) ? YES : NO; } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingKeepDisplayAspectEditable +{ + return [NSSet setWithObjects:@"anamorphicMode", nil]; +} + - (BOOL)isKeepDisplayAspectEditable { if (self.anamorphicMode == HB_ANAMORPHIC_STRICT || @@ -43,11 +56,21 @@ } } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingCustomAnamorphicEnabled +{ + return [NSSet setWithObjects:@"anamorphicMode", nil]; +} + - (BOOL)isCustomAnamorphicEnabled { return self.anamorphicMode == HB_ANAMORPHIC_CUSTOM; } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingInfo +{ + return [NSSet setWithObjects:@"parWidth", @"parHeight", @"displayWidth", @"width", @"height",@"anamorphicMode", @"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil]; +} + - (NSString *)info { NSString *sizeInfo = @""; @@ -98,6 +121,11 @@ return sizeInfo; } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingSummary +{ + return [NSSet setWithObjects:@"parWidth", @"parHeight", @"displayWidth", @"width", @"height",@"anamorphicMode", @"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil]; +} + - (NSString *)summary { NSMutableString *summary = [NSMutableString stringWithString:@""]; diff --git a/macosx/HBPicture.m b/macosx/HBPicture.m index 6760bf1e1..c0f7db15a 100644 --- a/macosx/HBPicture.m +++ b/macosx/HBPicture.m @@ -393,11 +393,21 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; #pragma mark - Max sizes ++ (NSSet<NSString *> *)keyPathsForValuesAffectingMaxWidth +{ + return [NSSet setWithObjects:@"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil]; +} + - (int)maxWidth { return self.sourceWidth - self.cropRight - self.cropLeft; } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingMaxHeight +{ + return [NSSet setWithObjects:@"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil]; +} + - (int)maxHeight { return self.sourceHeight - self.cropTop - self.cropBottom; @@ -418,38 +428,6 @@ NSString * const HBPictureChangedNotification = @"HBPictureChangedNotification"; return (int) (self.sourceWidth * self.sourceParNum / (double)self.sourceParDen); } -+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key -{ - NSSet *retval = nil; - - // Tell KVO to reload the editable state. - if ([key isEqualToString:@"keepDisplayAspectEditable"] || - [key isEqualToString:@"heightEditable"] || - [key isEqualToString:@"widthEditable"] || - [key isEqualToString:@"customAnamorphicEnabled"]) - { - retval = [NSSet setWithObjects:@"anamorphicMode", nil]; - } - - else if ([key isEqualToString:@"maxWidth"] || - [key isEqualToString:@"maxHeight"]) - { - retval = [NSSet setWithObjects:@"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil]; - } - - else if ([key isEqualToString:@"info"] || [key isEqualToString:@"summary"]) - { - retval = [NSSet setWithObjects:@"parWidth", @"parHeight", @"displayWidth", @"width", @"height",@"anamorphicMode", @"cropTop", @"cropBottom", @"cropLeft", @"cropRight", nil]; - } - - else - { - retval = [NSSet set]; - } - - return retval; -} - - (void)setNilValueForKey:(NSString *)key { if ([key isEqualToString:@"width"] || [key isEqualToString:@"height"]) |