mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-21 13:50:29 +00:00
updated example
This commit is contained in:
parent
d0345549f6
commit
ae5440ad11
@ -485,6 +485,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
#pragma mark - Helpers
|
#pragma mark - Helpers
|
||||||
- (NSString *)timeStringForCMTime:(CMTime)time
|
- (NSString *)timeStringForCMTime:(CMTime)time
|
||||||
{
|
{
|
||||||
|
//TODO: ask Max if delegate for this thing will be useful;
|
||||||
NSUInteger dTotalSeconds = CMTimeGetSeconds(time);
|
NSUInteger dTotalSeconds = CMTimeGetSeconds(time);
|
||||||
|
|
||||||
NSUInteger dHours = floor(dTotalSeconds / 3600);
|
NSUInteger dHours = floor(dTotalSeconds / 3600);
|
||||||
@ -493,9 +494,9 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
|
|
||||||
NSString *videoDurationText;
|
NSString *videoDurationText;
|
||||||
if (dHours > 0) {
|
if (dHours > 0) {
|
||||||
videoDurationText = [NSString stringWithFormat:@"%i:%01i:%02i", (int)dHours, (int)dMinutes, (int)dSeconds];
|
videoDurationText = [NSString stringWithFormat:@"%i:%02i:%02i", (int)dHours, (int)dMinutes, (int)dSeconds];
|
||||||
} else {
|
} else {
|
||||||
videoDurationText = [NSString stringWithFormat:@"%01i:%02i", (int)dMinutes, (int)dSeconds];
|
videoDurationText = [NSString stringWithFormat:@"%02i:%02i", (int)dMinutes, (int)dSeconds];
|
||||||
}
|
}
|
||||||
return videoDurationText;
|
return videoDurationText;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,12 +81,12 @@
|
|||||||
|
|
||||||
if (timeLabelType == ASVideoPlayerNodeControlTypeElapsedText) {
|
if (timeLabelType == ASVideoPlayerNodeControlTypeElapsedText) {
|
||||||
options = @{
|
options = @{
|
||||||
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:13.0],
|
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:16.0],
|
||||||
NSForegroundColorAttributeName: [UIColor orangeColor]
|
NSForegroundColorAttributeName: [UIColor orangeColor]
|
||||||
};
|
};
|
||||||
} else if (timeLabelType == ASVideoPlayerNodeControlTypeDurationText) {
|
} else if (timeLabelType == ASVideoPlayerNodeControlTypeDurationText) {
|
||||||
options = @{
|
options = @{
|
||||||
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:13.0],
|
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:16.0],
|
||||||
NSForegroundColorAttributeName: [UIColor redColor]
|
NSForegroundColorAttributeName: [UIColor redColor]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -98,19 +98,53 @@
|
|||||||
forControls:(NSDictionary *)controls
|
forControls:(NSDictionary *)controls
|
||||||
forConstrainedSize:(ASSizeRange)constrainedSize
|
forConstrainedSize:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
ASDisplayNode *scrubber = controls[@(ASVideoPlayerNodeControlTypeScrubber)];
|
|
||||||
if (scrubber) {
|
NSMutableArray *bottomControls = [[NSMutableArray alloc] init];
|
||||||
scrubber.preferredFrameSize = CGSizeMake(constrainedSize.max.width, 44.0);
|
NSMutableArray *topControls = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
ASDisplayNode *scrubberNode = controls[@(ASVideoPlayerNodeControlTypeScrubber)];
|
||||||
|
ASDisplayNode *playbackButtonNode = controls[@(ASVideoPlayerNodeControlTypePlaybackButton)];
|
||||||
|
ASTextNode *elapsedTexNode = controls[@(ASVideoPlayerNodeControlTypeElapsedText)];
|
||||||
|
ASTextNode *durationTexNode = controls[@(ASVideoPlayerNodeControlTypeDurationText)];
|
||||||
|
|
||||||
|
if (playbackButtonNode) {
|
||||||
|
[bottomControls addObject:playbackButtonNode];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scrubberNode) {
|
||||||
|
scrubberNode.preferredFrameSize = CGSizeMake(constrainedSize.max.width, 44.0);
|
||||||
|
[bottomControls addObject:scrubberNode];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elapsedTexNode) {
|
||||||
|
[topControls addObject:elapsedTexNode];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (durationTexNode) {
|
||||||
|
[topControls addObject:durationTexNode];
|
||||||
}
|
}
|
||||||
|
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||||
spacer.flexGrow = YES;
|
spacer.flexGrow = YES;
|
||||||
|
|
||||||
|
ASStackLayoutSpec *topBarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||||
|
spacing:10.0
|
||||||
|
justifyContent:ASStackLayoutJustifyContentCenter
|
||||||
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
|
children:topControls];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UIEdgeInsets topBarSpecInsets = UIEdgeInsetsMake(20.0, 10.0, 0.0, 10.0);
|
||||||
|
|
||||||
|
ASInsetLayoutSpec *topBarSpecInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:topBarSpecInsets child:topBarSpec];
|
||||||
|
topBarSpecInsetSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||||
|
|
||||||
ASStackLayoutSpec *controlbarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
ASStackLayoutSpec *controlbarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||||
spacing:10.0
|
spacing:10.0
|
||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsCenter
|
alignItems:ASStackLayoutAlignItemsCenter
|
||||||
children: @[scrubber] ];
|
children:bottomControls];
|
||||||
controlbarSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
controlbarSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||||
|
|
||||||
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
||||||
@ -123,7 +157,7 @@
|
|||||||
spacing:0.0
|
spacing:0.0
|
||||||
justifyContent:ASStackLayoutJustifyContentStart
|
justifyContent:ASStackLayoutJustifyContentStart
|
||||||
alignItems:ASStackLayoutAlignItemsStart
|
alignItems:ASStackLayoutAlignItemsStart
|
||||||
children:@[spacer,controlbarInsetSpec]];
|
children:@[ topBarSpecInsetSpec, spacer, controlbarInsetSpec ]];
|
||||||
|
|
||||||
|
|
||||||
return mainVerticalStack;
|
return mainVerticalStack;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user