AsyncDisplayKit is now Texture! LEARN MORE



ASVideoNode provides a convenient and performant way to display videos in your app.

Note: If you use `ASVideoNode` in your application, you must link `AVFoundation` since it uses `AVPlayerLayer` and other `AVFoundation` classes under the hood.

Basic Usage

The easiest way to use ASVideoNode is to assign it an AVAsset.

ASVideoNode *videoNode = [[ASVideoNode alloc] init];

AVAsset *asset = [AVAsset assetWithURL:[NSURL URLWithString:@""]];
videoNode.asset = asset;

Autoplay, Autorepeat, and Muting

You can configure the way your video node reacts to various events with a few simple BOOLs.

If you’d like your video to automaticaly play when it enters the visible range, set the shouldAutoplay property to YES. Setting shouldAutoRepeat to YES will cause the video to loop indefinitely, and, of course, setting muted to YES will turn the video’s sound off.

To set up a node that automatically plays once silently, you would just do the following.

videoNode.shouldAutoplay = YES;
videoNode.shouldAutorepeat = NO;
videoNode.muted = YES;

Placeholder Image

Since video nodes inherit from ASNetworkImageNode, you can use the URL property to assign a placeholder image. If you decide not to, the first frame of your video will automatically decoded and used as the placeholder instead.

ASVideoNode Delegate

There are a ton of delegate methods available to you that allow you to react to what’s happening with your video. For example, if you want to react to the player’s state changing, you can use:

- (void)videoNode:(ASVideoNode *)videoNode willChangePlayerState:(ASVideoNodePlayerState)state toState:(ASVideoNodePlayerState)toState;

The easiest way to see them all is to take a look at the ASVideoNode header file.

Edit on GitHub