I have an app that allows a user to record a video in a mutable composition. I'd like to set some text that will come up and then change at an interval that I set when the user plays it back after an export.
For example, if the first word is "dog", then i'd like to set it up so that "cat" replaces that string X seconds later, and then is replaced with another word X seconds later.
私のビデオは AVExportSession を使用して AVMutableComposition からエクスポートされ、次のように追加された CATextlayer を使用して私の言葉が追加されます。
//code to setup AVMutableComposition
...
//code to setup CATextLayer and AVMutableVideoComposition
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];
//code to setup AVExportSession
...
私の質問は、指定した文字列に設定した間隔でテキストを変更するにはどうすればよいですか?
どんな提案でも大歓迎です。