public final class

RecordingConfig

extends Object
java.lang.Object
   ↳ co.megacool.megacool.RecordingConfig

Class Overview

Customize how a recording is done and how it's encoded into something that can be shared.

Summary

Public Constructors
RecordingConfig()
Create new RecordingConfig.
Public Methods
RecordingConfig frameRate(int frameRate)
How often new frames should be recorded, in frames per second.
int getFrameRate()
Get the recording's capture frame rate, in frames per second.
int getLastFrameDelay()
Get the recording's last frame delay, in milliseconds.
int getLastFrameOverlay()
Get the recording's last frame overlay drawable.
String getLastFrameOverlayAsset()
Get the recording's last frame overlay asset.
int getMaxFrames()
Get the recording's max length in frames.
OverflowStrategy getOverflowStrategy()
Get the recording's overflow strategy.
double getPeakLocation()
Get the recording's peak location.
int getPlaybackFrameRate()
Get the recording's playback frame rate, in frames per second.
String getRecordingId()
Get the recording's identifier.
RecordingConfig id(String id)
Set an identifier for a recording, to be able to preview or share it again later.
RecordingConfig lastFrameDelay(int delay)
Set how long to pause the GIF on the last frame, in ms.
RecordingConfig lastFrameOverlay(int lastFrameOverlay)
Set the image that will be overlayed on the last frame of the gif
RecordingConfig lastFrameOverlayAsset(String lastFrameOverlayAsset)
Set the image that will be overlayed on the last frame of the gif
RecordingConfig maxFrames(int maxFrames)
Set the max number of frames in a recording.
RecordingConfig overflowStrategy(OverflowStrategy overflowStrategy)
Define how recordings longer than the specified max frames should be compressed.
RecordingConfig peakLocation(double peakLocation)
Set the location of the highest scoring moment (the peak) in a highlight recording.
RecordingConfig playbackFrameRate(int playbackFrameRate)
The frame rate the recording will be played back in.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public RecordingConfig ()

Create new RecordingConfig.

Globals modified after instantiating a RecordingConfig has no effect on the given RecordingConfig.

Public Methods

public RecordingConfig frameRate (int frameRate)

How often new frames should be recorded, in frames per second.

This is only relevant when you use startRecording(View, RecordingConfig), as when you use captureFrame(View, RecordingConfig) the frames will be captured in the rate you call captureFrame.

The upper limit here will be restricted by how fast captures can occur on the given device, if set too high we'll just capture as many frames per second as possible, and you'll see highly variable results between devices. You probably shouldn't set this higher than 15-20 to avoid too much performance impact from the recording.

Calling this method will automatically update the playback frame rate to be 20% more than the value passed in for frameRate, unless you've previously called playbackFrameRate(int)

Parameters
frameRate how frames to capture per second
Returns
  • the config

public int getFrameRate ()

Get the recording's capture frame rate, in frames per second.

Returns
  • the capture frame rate

public int getLastFrameDelay ()

Get the recording's last frame delay, in milliseconds.

Returns
  • the last frame delay in ms

public int getLastFrameOverlay ()

Get the recording's last frame overlay drawable.

Returns
  • the last frame overlay drawable.

public String getLastFrameOverlayAsset ()

Get the recording's last frame overlay asset.

Returns
  • the last frame overlay asset.

public int getMaxFrames ()

Get the recording's max length in frames.

Returns
  • the max length in frames

public OverflowStrategy getOverflowStrategy ()

Get the recording's overflow strategy.

Returns
  • the overflow strategy

public double getPeakLocation ()

Get the recording's peak location.

Returns
  • the peak location

public int getPlaybackFrameRate ()

Get the recording's playback frame rate, in frames per second.

Returns
  • the playback frame rate

public String getRecordingId ()

Get the recording's identifier.

Returns
  • the recording identifier

public RecordingConfig id (String id)

Set an identifier for a recording, to be able to preview or share it again later. To be able to store multiple completed recordings on disk you must also remember to set setKeepCompletedRecordings(boolean) to true.

Parameters
id the recording identifier
Returns
  • the config

public RecordingConfig lastFrameDelay (int delay)

Set how long to pause the GIF on the last frame, in ms. Must be a non-negative integer, default is 1000.

If you pass 0, the delay will be the same as the other frames.

Parameters
delay how long to pause on the last frame
Returns
  • the config

public RecordingConfig lastFrameOverlay (int lastFrameOverlay)

Set the image that will be overlayed on the last frame of the gif

Parameters
lastFrameOverlay the image to overlay
Returns
  • the config

public RecordingConfig lastFrameOverlayAsset (String lastFrameOverlayAsset)

Set the image that will be overlayed on the last frame of the gif

Parameters
lastFrameOverlayAsset the name of the asset with the last frame overlay image
Returns
  • the config

public RecordingConfig maxFrames (int maxFrames)

Set the max number of frames in a recording. Must be larger than 2.

If the overflow strategy is set to TIMELAPSE, the resulting GIF might have a frame count between 1.33x and 0.66x what is set as max.

Parameters
maxFrames the max number of frames
Returns
  • the config

public RecordingConfig overflowStrategy (OverflowStrategy overflowStrategy)

Define how recordings longer than the specified max frames should be compressed.

Parameters
overflowStrategy the overflow strategy
Returns
  • the config
See Also

public RecordingConfig peakLocation (double peakLocation)

Set the location of the highest scoring moment (the peak) in a highlight recording. Must be between 0 and 1, the default is 0.7. Set the score throughout the game with registerScoreChange(). The recording must be using the highlight overflow strategy for this to have any effect.

For example, in a recording with 10 frames, a peak location of 0.2 means that the highest scoring frame will occur near the beginning at frame 2, and a peakLocation of 0.8 means that the peak will occur near the end at frame 8.

Parameters
peakLocation percentage of frames in the recording to include before the peak
Returns
  • the config

public RecordingConfig playbackFrameRate (int playbackFrameRate)

The frame rate the recording will be played back in. Should be identical to the recording frame rate set with frameRate(int) to play back in real time, set higher to speed up the recording or lower to slow it down. The max is 100fps, but you're unlikely to see browser play it back at that rate, thus you should keep the rate in the 5-25 range to stay sane.

Parameters
playbackFrameRate the playback frame rate, as frames per second
Returns
  • the config
See Also
  • GIF89 spec (https://www.w3.org/Graphics/GIF/spec-gif89a.txt), section vii, for details on GIF max frame rate

public String toString ()