Types of recording

Time recording

Add the following line of code where you want to start a recording:


The recording will by default keep a buffer of the last 5 seconds. Old frames get overwritten by new frames. See Max Frames for editing the default setting.

Note: If your app goes to the background, pauseRecording is called automatically, but it's not automatically resumed when the app opens again.

To end a recording, add the following line of code:


Highlight recording

The highlight recording feature records the ‘most interesting’ part of your game--whether this is an awesome action sequence, or a hilarious ‘fail’. It does this by keeping track of the gameplay's intensity as determined by metrics specific to your game.

Whenever a critical event (such as scoring a point, landing a cool combo, failing in an epic way, etc.) occurs, call this function to make note of the event (and optionally, its intensity):

Megacool.getInstance().registerScoreChange(); // without intensity
Megacool.getInstance().registerScoreChange(42); // with intensity of 42

For easy integration, we suggest ‘piggy-backing’ off your game’s current score system by calling this function whenever the player’s score increases, with the amount that it increases by. We equate ‘intensity’ with a change in point value, but you can also experiment with assigning various intensities to events with subjective ‘cool’ value.

Add the following line of code at the beginning of your game to start capturing your highlight!

RecordingConfig config = new RecordingConfig()
Megacool.getInstance().startRecording(view, config);

Peak location

Different games have different paces: in one game, an awesome move might be followed immediately by bland downtime, while in another game, there might be some cool graphics or an interesting cutscene immediately afterwards. To let you adjust how much to include after the action dies down, try experimenting with the peakLocation parameter. This parameter is specific to highlight recording and controls where the ‘peak’ (or, maximum change in point value) of your highlight occurs. In the previous example, we would want the first game to have a late peak location so we don't record too much boring downtime, and the first game to have an early peak location so we make sure to record the cool after-graphics. The value of the peak location (between 0 and 1, inclusive), determines at what percentage through the recording the peak will be placed.

For example, in a recording with 10 frames, a peakLocation of 0.2 means that the peak will occur near the beginning around frame 2, and a peakLocation of 0.8 means that the peak will occur near the end around frame 8. The default peakLocation is 0.7. You can set the peak location by calling:

Megacool.getInstance().captureFrame(view, new RecordingConfig()

Capture individual frames

Capture each frame of the recording, e.g. on each user tap:


By default max 50 frames will be captured. If it exceeds 50 frames, old frames are overwritten until Megacool.getInstance().stopRecording() gets called to reset it. Add the following line of code to stop a recording:



Timelapse is identical to the normal captureFrame, except timelapse has different behavior when overflowing maxFrames. If it's about to overflow, it will delete every other frame captured so far, and half the rate of capturing (thus only storing every second image on the first overflow, every fourth image on the next, and so on).

Megacool.getInstance().captureFrame(view, new RecordingConfig()

If you want to guarantee that a frame is added to the timelapse (like an end screen or final state of the game), pass a forceAdd = true parameter to captureFrame like this:

Megacool.getInstance().captureFrame(view, null, true);

Important: Only pass this parameter once! Normally this function returns as soon as it has spawned a thread to do the actual capture, but if you pass forceAdd = true it will run synchronously (e.g. not return until it has actually stored the frame. This is because usually this is called as the last step before a session ends and the GIF is created, thus we need the call to complete before creating the GIF. This enables you to change visible elements on the screen after this call completes and be sure that it's not going to be included in the GIF.

Rendering preview

This creates a rendered preview of the GIF that can be displayed to the user before sharing.

GifImageView gifImageView = Megacool.getInstance().renderPreviewOfGif();
if (gifImageView != null) {

Recording frame rate

Set numbers of frames to record per second. Recommended range: 1 - 10. The default is 10:

Megacool.getInstance().startRecording(view, new RecordingConfig()

Note: This only applies to recordings made with Megacool.getInstance().startRecording(view), not Megacool.getInstance().captureFrame(view).

Frame rate examples (with Playback frame rate: 10):

Frame rate: 5
Frame rate: 10
Frame rate: 25

Playback frame rate

Set the number of frames per second when playing the GIF. The default is 12 frames / second. The GIF will be exported with this frame rate and it doesn't affect the recording frame rate. Setting this value higher than the frame rate causes the recording to be sped up, setting it lower means it'll be slowed down.

Megacool.getInstance().startRecording(view, new RecordingConfig()
Playback frame rate: 5
Playback frame rate: 10
Playback frame rate: 25

Max frames

Max number of frames to record, default is 50 frames. Change the maximum amount of captured frames by setting:

Megacool.getInstance().startRecording(view, new RecordingConfig()
Max frames: 25
Max frames: 50
Max frames: 100

Delay last frame

Set a delay (in milliseconds) for the last frame of the GIF. The default is 1 second to give a natural break before the GIF loops again.

Megacool.getInstance().startRecording(view, new RecordingConfig()
No extra delay on the last frame
1000 ms delay (default)
2000 ms delay

Last frame overlay

With last frame overlay you can add a transparent image on top of the last GIF frame.

+ =

Megacool.getInstance().startRecording(view, new RecordingConfig()

Color table

A gif consists of 256 colors and there are three different ways we can compute those colors, with slightly varying quality and performance tradeoffs. Default is dynamic.


The frames are analyzed before encoding, yielding a good balance between quality and speed. This is the default.

Analyze first

The frames are analyzed before encoding to generate a representative color table. This requires more CPU to create the GIF, but often yields better results when a GIF contains many shades of the same color. This option is only available on iOS, on Android the dynamic color table will be used instead.

Save recordings

Being able to save and resume recordings is useful for combining multiple game sessions together. These recordings are stored to disk to be retrieved and potentially resumed later. This is a great case for turn-based games like Words with Friends where waiting for the other user to finish the round could take many hours, and still create a GIF of the whole game play.

Start and resume a recording

All completed recordings will by default be deleted whenever a new recording is started with either Megacool.getInstance().captureFrame(view) or Megacool.getInstance().startRecording(view). To save a recording you can set Megacool.getInstance().setKeepCompletedRecordings(true);

To save multiple recordings you can set a recording id in a RecordingConfig object. The recording id can be anything you prefer, for instance a name of the current level like "level3".

A recording with a given RecordingId can be resumed until Megacool.getInstance().stopRecording() is called. After calling Megacool.getInstance().stopRecording() you can either share the recording or start a new one from scratch with the same RecordingId.

Megacool.getInstance().startRecording(view, new RecordingConfig().id("level3"));

Pause recording

When you want to pause a recording that can be continued later, you call pauseRecording.


Delete recording

deleteRecording will remove any frames of the recording in memory and on disk. Both completed and incomplete recordings will take space on disk, thus particularly if you're using Megacool.getInstance().setKeepCompletedRecordings(true); you might want to provide an interface to your users for removing recordings they don't care about anymore to free up space for new recordings.


Show a GIF from a specific recording

To show a GIF from a specific recording:

GifImageView gifImageView = Megacool.getInstance().renderPreviewOfGif("level3");
if (gifImageView != null) {

Share a GIF from a specific recording

To share a GIF from a specific recording you pass the RecordingId as a parameter to share.

Megacool.getInstance().share(context, new ShareConfig()

Note: Megacool.getInstance().share(context) calls pauseRecording automatically, so if you haven't called Megacool.getInstance().stopRecording() before next time you call Megacool.getInstance().startRecording(view), the recording will continue from where you paused.