Skip to content

Instantly share code, notes, and snippets.

@GeekTree0101
Last active February 12, 2019 00:55
Show Gist options
  • Save GeekTree0101/d17460c1fff9cc606e9791d0c36ef76e to your computer and use it in GitHub Desktop.
Save GeekTree0101/d17460c1fff9cc606e9791d0c36ef76e to your computer and use it in GitHub Desktop.
Answer
class DisplayNode: ASCellNode {
lazy var videoNode: ASVideoNode = {
let node = ASVideoNode()
node.backgroundColor = UIColor.gray
node.shouldAutoplay = true
node.shouldAutorepeat = true
node.muted = true
return videoNode
}
override init() {
super.init()
self.automaticallyManagesSubnodes = true
guard let url = URL(string: "https://www.radiantmediaplayer.com/media/bbb-360p.mp4") else { return }
let asset = AVAsset(url: url)
self.videoNode.asset = asset
}
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
return ASInsetLayoutSpec(insets: .zero, child: videoNode)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment