'How to set the start time of MediaClips in c# MediaComposition?

I have a UWP Desktop application in which I use a MediaComposition with multiple images. The problem is that all images have a specific time to appear and a duration. How do I set the start time for each MediaClip?

MediaComposition mediaComposition = new MediaComposition();

var clipCover = await MediaClip.CreateFromImageFileAsync(stgCover, tmsCompositionDuration);
mediaComposition.Clips.Add(clip);


Solution 1:[1]

How to set the start time of MediaClips in c# MediaComposition?

Currently, there is not such api to set start time for the MediaClip, you just make image clip with specific duration and insert it into mediaComposition list. for the start time, you need calculate it manually (previous clips duration summation).

For your scenario, you could use MediaClip.CreateFromColor to make empty color frame and insert it into specific index to update the clip's start time.

for more detail, please refer to this Media compositions and editing tutorial.

Solution 2:[2]

You can use Overlays: Because overlays are stacked on top of each other instead of being played sequentially, all overlays start playback at the beginning of the composition by default. To cause an overlay to be begin playback at another time, set the Delay property to the desired time offset (source)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nico Zhu - MSFT
Solution 2 DosU