What do I need it for?
You can use this feature to make some cool image-based animation. For example, make the animated logo appearance - displaying - hiding. All you need to do is separate the image sequence animation playback into this steps and control the animation playback: play the intro part, pause on displaying part and then unpause to playback the hiding part.
How to pause the image sequence on a needed frame?
The main idea of playback control is calculating the frames being showed after the sequence appearance and pause on a needed one.
Here is a sequence of actions:
1. Make some preparations: create a CG object, add it as a plugin and subscribe to its OnFrame event.
Note: You should handle the CG OnFrame event, not the playlist one.
// Create the CG object m_objCharGen = new MLCHARGENLib.CoMLCharGen(); // Add it as plugin to the Playlist object m_objPlaylist.PluginsAdd(m_objCharGen, 0); // Subscribe to CG OnFrame event m_objCharGen.OnFrame += new MLCHARGENLib.IMLCharGenEvents_OnFrameEventHandler(M_objCharGen_OnFrame);
2. Prepare the CG OnFrame event handling method. It will calculate the shown frames after displaying your sequence and pause the sequence playback when the required frame is reached.
// The flag that indicates that sequence is shown. private bool isSequenceShownFlag = false; // The ID of the item that should be paused. private string theItemToPause; // Frame counter private int frameCounter; // The frame you plan to pause on. private int targetFrame; // The CG OnFrame handling method private void M_objCharGen_OnFrame(double dblTime, int nMediaTime, int nFrameNum) { // If the item is shown... if (isSequenceShownFlag) { // ... calculate the frames ... frameCounter++; // ... and pause the item when required frame number is reached if (targetFrame == frameCounter) { m_objCharGen.PauseItem(theItemToPause, 1); } } }
3. Add your sequence to the CG object.
// The Id of my sequence string graphicsItemId = "myImageSequence"; // A path to the folder with image sequence string path = @"D:\MySequences\LogoSequence\*.*"; // Add the sequence as CG item. Note that I add it as hidden one. m_objCharGen.AddNewItem(pathToFlashFile, 0.05, 0.05, 1, 0, ref graphicsItemId);
4. Show the sequence and start calculating the frames with OnFrame event.
// Show the item m_objCharGen.ShowItem("myImageSequence", 1, 1000); // Set the CG item name that should be paused theItemToPause = "myImageSequence"; // Zero the frame counter. frameCounter = 0; // Set the frame number to pause item on. targetFrame = 100; // Inform the counter that the item is shown. isSequenceShownFlag = true;
Once the counter will reach the 100 frame it will pause the image sequence.