I have an application that allows the user to record video in a mutable composition. I would like to set some kind of text that will appear and then change at the interval that I set when the user plays it after export.
For example, if the first word is “dog”, then I would like to configure it so that “cat” replaces this string X seconds later, and then is replaced by another word after X seconds.
My video is exported from AVMutableComposition using AVExportSession, and my words will be added using the CATextlayer added to it as follows:
...
CALayer *animatedTitleLayer = [CALayer layer];
CATextLayer *titleLayer = [[CATextLayer alloc] init];
titleLayer.string = @"Text I want to change at an interval";
titleLayer.alignmentMode = kCAAlignmentCenter;
titleLayer.bounds = CGRectMake(150, 50, 124, 354);
titleLayer.position = CGPointMake(120, 270);
titleLayer.bounds = CGRectIntegral(CGRectMake(0, 0, 250, 150));
titleLayer.opacity = 1;
titleLayer.backgroundColor = [UIColor purpleColor].CGColor;
[animatedTitleLayer addSublayer:titleLayer];
animatedTitleLayer.position = CGPointMake(40, 5);
CALayer *parentLayer = [CALayer layer];
CALayer *videoLayer = [CALayer layer];
parentLayer.frame = CGRectMake(0, 0, 320, 480);
videoLayer.frame = CGRectMake(0, 0, 320, 480);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:animatedTitleLayer];
parentLayer.preferredTransform = rotationTransform;
AVMutableVideoComposition *videoComposition;
videoComposition = [AVMutableVideoComposition videoComposition];
videoComposition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];
...
My question is: how can I change the text at the interval that I set for the lines that I designated?
.