Skip to content

Commit e87fd7a

Browse files
committed
first steps
1 parent e953198 commit e87fd7a

17 files changed

Lines changed: 842 additions & 0 deletions

File tree

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@
302302
7AB338691C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AB338681C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm */; };
303303
81EE384F1C8E94F000456208 /* ASRunLoopQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 81EE384D1C8E94F000456208 /* ASRunLoopQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
304304
81EE38501C8E94F000456208 /* ASRunLoopQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 81EE384E1C8E94F000456208 /* ASRunLoopQueue.mm */; };
305+
8BDA5FC51CDBDDE1007D13B2 /* ASVideoPlayerNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BDA5FC31CDBDDE1007D13B2 /* ASVideoPlayerNode.h */; };
306+
8BDA5FC61CDBDDE1007D13B2 /* ASVideoPlayerNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8BDA5FC41CDBDDE1007D13B2 /* ASVideoPlayerNode.mm */; };
307+
8BDA5FC71CDBDF91007D13B2 /* ASVideoPlayerNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BDA5FC31CDBDDE1007D13B2 /* ASVideoPlayerNode.h */; };
308+
8BDA5FC81CDBDF95007D13B2 /* ASVideoPlayerNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8BDA5FC41CDBDDE1007D13B2 /* ASVideoPlayerNode.mm */; };
305309
92074A611CC8BA1900918F75 /* ASImageNode+tvOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 92074A5F1CC8BA1900918F75 /* ASImageNode+tvOS.h */; };
306310
92074A621CC8BA1900918F75 /* ASImageNode+tvOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 92074A5F1CC8BA1900918F75 /* ASImageNode+tvOS.h */; };
307311
92074A631CC8BA1900918F75 /* ASImageNode+tvOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 92074A601CC8BA1900918F75 /* ASImageNode+tvOS.m */; };
@@ -794,6 +798,8 @@
794798
7AB338681C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASRelativeLayoutSpecSnapshotTests.mm; sourceTree = "<group>"; };
795799
81EE384D1C8E94F000456208 /* ASRunLoopQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASRunLoopQueue.h; path = ../ASRunLoopQueue.h; sourceTree = "<group>"; };
796800
81EE384E1C8E94F000456208 /* ASRunLoopQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASRunLoopQueue.mm; path = ../ASRunLoopQueue.mm; sourceTree = "<group>"; };
801+
8BDA5FC31CDBDDE1007D13B2 /* ASVideoPlayerNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASVideoPlayerNode.h; sourceTree = "<group>"; };
802+
8BDA5FC41CDBDDE1007D13B2 /* ASVideoPlayerNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASVideoPlayerNode.mm; sourceTree = "<group>"; };
797803
92074A5F1CC8BA1900918F75 /* ASImageNode+tvOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASImageNode+tvOS.h"; sourceTree = "<group>"; };
798804
92074A601CC8BA1900918F75 /* ASImageNode+tvOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASImageNode+tvOS.m"; sourceTree = "<group>"; };
799805
92074A651CC8BADA00918F75 /* ASControlNode+tvOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASControlNode+tvOS.h"; sourceTree = "<group>"; };
@@ -1035,6 +1041,8 @@
10351041
92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */,
10361042
AEEC47DF1C20C2DD00EC1693 /* ASVideoNode.h */,
10371043
AEEC47E01C20C2DD00EC1693 /* ASVideoNode.mm */,
1044+
8BDA5FC31CDBDDE1007D13B2 /* ASVideoPlayerNode.h */,
1045+
8BDA5FC41CDBDDE1007D13B2 /* ASVideoPlayerNode.mm */,
10381046
055F1A3A19ABD43F004DAFF1 /* ASCellNode.h */,
10391047
AC6456071B0A335000CF11B8 /* ASCellNode.mm */,
10401048
18C2ED7C1B9B7DE800F627B3 /* ASCollectionNode.h */,
@@ -1529,6 +1537,7 @@
15291537
DBDB83941C6E879900D0098C /* ASPagerFlowLayout.h in Headers */,
15301538
058D0A4F195D05CB00B7D73C /* ASImageNode.h in Headers */,
15311539
05F20AA41A15733C00DCA68A /* ASImageProtocols.h in Headers */,
1540+
8BDA5FC51CDBDDE1007D13B2 /* ASVideoPlayerNode.h in Headers */,
15321541
430E7C8F1B4C23F100697A4C /* ASIndexPath.h in Headers */,
15331542
ACF6ED221B17843500DA7C62 /* ASInsetLayoutSpec.h in Headers */,
15341543
ACF6ED4B1B17847A00DA7C62 /* ASInternalHelpers.h in Headers */,
@@ -1740,6 +1749,7 @@
17401749
B350623A1B010EFD0018CF92 /* NSMutableAttributedString+TextKitAdditions.h in Headers */,
17411750
044284FF1BAA3BD600D16268 /* UICollectionViewLayout+ASConvenience.h in Headers */,
17421751
B35062431B010EFD0018CF92 /* UIView+ASConvenience.h in Headers */,
1752+
8BDA5FC71CDBDF91007D13B2 /* ASVideoPlayerNode.h in Headers */,
17431753
);
17441754
runOnlyForDeploymentPostprocessing = 0;
17451755
};
@@ -2053,6 +2063,7 @@
20532063
055F1A3519ABD3E3004DAFF1 /* ASTableView.mm in Sources */,
20542064
058D0A17195D050800B7D73C /* ASTextNode.mm in Sources */,
20552065
257754AC1BEE44CD00737CA5 /* ASTextKitRenderer.mm in Sources */,
2066+
8BDA5FC61CDBDDE1007D13B2 /* ASVideoPlayerNode.mm in Sources */,
20562067
ACC945AB1BA9E7C1005E1FB8 /* ASViewController.m in Sources */,
20572068
B0F8805B1BEAEC7500D17647 /* ASTableNode.m in Sources */,
20582069
205F0E221B376416007741D0 /* CGRect+ASConvenience.m in Sources */,
@@ -2195,6 +2206,7 @@
21952206
B35062091B010EFD0018CF92 /* ASScrollNode.m in Sources */,
21962207
B35062561B010EFD0018CF92 /* ASSentinel.m in Sources */,
21972208
9C8221981BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
2209+
8BDA5FC81CDBDF95007D13B2 /* ASVideoPlayerNode.mm in Sources */,
21982210
34EFC7721B701D0300AD841F /* ASStackLayoutSpec.mm in Sources */,
21992211
34EFC7761B701D2A00AD841F /* ASStackPositionedLayout.mm in Sources */,
22002212
7AB338661C55B3420055FDE8 /* ASRelativeLayoutSpec.mm in Sources */,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// ASVideoPlayerNode.h
3+
// AsyncDisplayKit
4+
//
5+
// Created by Erekle on 5/6/16.
6+
// Copyright © 2016 Facebook. All rights reserved.
7+
//
8+
9+
#if TARGET_OS_IOS
10+
#import <AsyncDisplayKit/AsyncDisplayKit.h>
11+
//#import <AsyncDisplayKit/ASThread.h>
12+
//#import <AsyncDisplayKit/ASVideoNode.h>
13+
//#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
14+
15+
@class AVAsset;
16+
17+
NS_ASSUME_NONNULL_BEGIN
18+
19+
@interface ASVideoPlayerNode : ASDisplayNode
20+
21+
- (instancetype)initWithUrl:(NSURL*)url;
22+
- (instancetype)initWithAsset:(AVAsset*)asset;
23+
@end
24+
NS_ASSUME_NONNULL_END
25+
#endif
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
//
2+
// ASVideoPlayerNode.m
3+
// AsyncDisplayKit
4+
//
5+
// Created by Erekle on 5/6/16.
6+
// Copyright © 2016 Facebook. All rights reserved.
7+
//
8+
9+
#import "ASVideoPlayerNode.h"
10+
11+
static NSString * const kASVideoPlayerNodePlayButton = @"playButton";
12+
13+
@interface ASVideoPlayerNode()
14+
{
15+
ASDN::RecursiveMutex _videoPlayerLock;
16+
17+
NSURL *_url;
18+
AVAsset *_asset;
19+
20+
ASVideoNode *_videoNode;
21+
22+
ASDisplayNode *_controlsHolderNode;
23+
24+
NSArray *_neededControls;
25+
26+
NSMutableDictionary *_cachedControls;
27+
}
28+
29+
@end
30+
31+
@implementation ASVideoPlayerNode
32+
- (instancetype)init
33+
{
34+
if (!(self = [super init])) {
35+
return nil;
36+
}
37+
38+
[self privateInit];
39+
40+
return self;
41+
}
42+
43+
- (instancetype)initWithUrl:(NSURL*)url
44+
{
45+
if (!(self = [super init])) {
46+
return nil;
47+
}
48+
49+
_url = url;
50+
51+
[self privateInit];
52+
53+
return self;
54+
}
55+
56+
- (instancetype)initWithAsset:(AVAsset *)asset
57+
{
58+
if (!(self = [super init])) {
59+
return nil;
60+
}
61+
62+
_asset = asset;
63+
64+
[self privateInit];
65+
66+
return self;
67+
}
68+
69+
- (void)privateInit
70+
{
71+
72+
_neededControls = [self createNeededControlElementsArray];
73+
_cachedControls = [[NSMutableDictionary alloc] init];
74+
75+
_videoNode = [[ASVideoNode alloc] init];
76+
_videoNode.asset = [AVAsset assetWithURL:_url];
77+
[self addSubnode:_videoNode];
78+
79+
_controlsHolderNode = [[ASDisplayNode alloc] init];
80+
_controlsHolderNode.backgroundColor = [UIColor greenColor];
81+
[self addSubnode:_controlsHolderNode];
82+
83+
[self createControls];
84+
}
85+
86+
- (NSArray*)createNeededControlElementsArray
87+
{
88+
//TODO:: Maybe here we will ask delegate what he needs and we force delegate to use our static strings or something like that
89+
return @[kASVideoPlayerNodePlayButton];
90+
}
91+
92+
#pragma mark - UI
93+
- (void)createControls
94+
{
95+
for (NSString *controlType in _neededControls) {
96+
if ([controlType isEqualToString:kASVideoPlayerNodePlayButton]) {
97+
[self createPlayButton];
98+
}
99+
}
100+
}
101+
102+
- (void)createPlayButton
103+
{
104+
ASControlNode *playButton = [_cachedControls objectForKey:kASVideoPlayerNodePlayButton];
105+
if (!playButton) {
106+
playButton = [[ASControlNode alloc] init];
107+
playButton.preferredFrameSize = CGSizeMake(20.0, 20.0);
108+
playButton.backgroundColor = [UIColor redColor];
109+
110+
[_cachedControls setObject:playButton forKey:kASVideoPlayerNodePlayButton];
111+
}
112+
113+
[self addSubnode:playButton];
114+
}
115+
116+
#pragma mark - Layout
117+
- (ASLayoutSpec*)layoutSpecThatFits:(ASSizeRange)constrainedSize
118+
{
119+
_videoNode.preferredFrameSize = constrainedSize.max;
120+
121+
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
122+
spacer.flexGrow = YES;
123+
124+
ASStackLayoutSpec *controlsSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
125+
spacing:0.0
126+
justifyContent:ASStackLayoutJustifyContentStart
127+
alignItems:ASStackLayoutAlignItemsStart
128+
children:[_cachedControls allValues]];
129+
130+
UIEdgeInsets insets = UIEdgeInsetsMake(8.0, 8.0, 8.0, 8.0);
131+
132+
ASInsetLayoutSpec *controlsInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:controlsSpec];
133+
134+
ASStackLayoutSpec *mainVerticalStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical
135+
spacing:0.0
136+
justifyContent:ASStackLayoutJustifyContentStart
137+
alignItems:ASStackLayoutAlignItemsStart
138+
children:@[spacer,controlsInsetSpec]];
139+
140+
141+
ASOverlayLayoutSpec *overlaySpec = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:_videoNode overlay:mainVerticalStack];
142+
143+
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[overlaySpec]];
144+
}
145+
146+
@end
17.1 KB
Loading
17.9 KB
Loading
22.8 KB
Loading

examples/ASDKTube/Podfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source 'https://github.com/CocoaPods/Specs.git'
2+
platform :ios, '7.0'
3+
target 'Sample' do
4+
pod 'AsyncDisplayKit', :path => '../..'
5+
end

0 commit comments

Comments
 (0)