java.lang.Object | |
↳ | co.megacool.megacool.Megacool |
The main interface to the Megacool SDK. Make sure you call
start(Context, String, OnEventsReceivedListener)
early in the app lifecycle,
preferably in your app's Application
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
enum | Megacool.CaptureMethod | Used to specify how captures should be performed. | |||||||||
interface | Megacool.OnEventsReceivedListener | Event listener used in start(Context, String, OnEventsReceivedListener) . |
|||||||||
interface | Megacool.OnUserIdReceivedListener | Listener to get the user id for this device. | |||||||||
interface | Megacool.ShareCallback | Listener to get the latest updated list of Share objects in
getShares(ShareCallback) . |
|||||||||
interface | Megacool.ShareFilter | A filter to pass to getShares(ShareCallback, ShareFilter) to only get a
selected types of shares back, like INSTALLED . |
|||||||||
interface | Megacool.ShareListener | Listener to respond to share completion/dismissal. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
captureFrame(View view)
Capture a single frame of the provided View.
| ||||||||||
void |
captureFrame(View view, RecordingConfig config)
Capture a single frame of provided View with additional configuration.
| ||||||||||
void |
captureFrame(View view, RecordingConfig config, boolean forceAdd)
Capture a single frame of provided View with additional configuration.
| ||||||||||
void |
deleteRecording(String recordingId)
Delete a recording
Will remove any frames of the recording in memory and on disk. | ||||||||||
void |
deleteShares(Megacool.ShareFilter filter)
Delete sent share objects that's not relevant anymore
Use the | ||||||||||
RecordingConfig |
getDefaultRecordingConfig()
Get the default recording config.
| ||||||||||
ShareConfig |
getDefaultShareConfig()
Get the default share config.
| ||||||||||
int |
getFrameRate(String recordingId)
Get the capture frame rate for a recording with the given id
| ||||||||||
static Megacool |
getInstance()
Get the Megacool singleton instance
| ||||||||||
int |
getNumberOfFrames(String recordingId)
Get the number of frames that exist for a recording with the
given id
| ||||||||||
PreviewData |
getPreviewDataForRecording(String recordingId)
Get the raw data needed to build your own preview.
| ||||||||||
List<Share> |
getShares(Megacool.ShareCallback callback, Megacool.ShareFilter filter)
Get a list of the sent share objects, filtered.
| ||||||||||
List<Share> |
getShares(Megacool.ShareCallback callback)
Get a list of the sent share objects.
| ||||||||||
static boolean |
handleDeepLink(Uri url)
Entry point for handling links with Megacool.
| ||||||||||
static void |
initRenderThread()
Wrapper for the native method mcl_init_render_thread.
| ||||||||||
static void |
notifyRenderComplete()
Wrapper for the native method mcl_notify_render_complete.
| ||||||||||
void |
pauseRecording()
Pauses the current recording for resumption later.
| ||||||||||
void |
registerScoreChange(int scoreDelta)
Used by the HighlightOverflowStrategy in order to keep track of the intensity of the game.
| ||||||||||
void |
registerScoreChange()
Used by the HighlightOverflowStrategy in order to keep track of the intensity of the game.
| ||||||||||
GifImageView |
renderPreviewOfGif()
Render preview of GIF that can be showed before sharing.
| ||||||||||
GifImageView |
renderPreviewOfGif(String recordingId)
Render preview of specific GIF recording that can be showed before sharing.
| ||||||||||
static void |
resetIdentity()
(For testing purposes) resets the device identity, enabling it to receive events
isFirstSession() again. | ||||||||||
void |
setCaptureMethod(Megacool.CaptureMethod captureMethod, double scaleFactor)
Set how screen captures should be performed, using a custom scale factor.
| ||||||||||
void |
setCaptureMethod(Megacool.CaptureMethod captureMethod)
Set how screen captures should be performed, using the default scale factor.
| ||||||||||
static void |
setDebug(boolean enabled)
Enables writing debug info from Megacool to logcat and saving call traces to submit to the
core developers.
| ||||||||||
void |
setDefaultRecordingConfig(RecordingConfig config)
Set the default recording config.
| ||||||||||
void |
setDefaultShareConfig(ShareConfig config)
Set the default share config.
| ||||||||||
void |
setGifColorTable(GifColorTable colorTable)
Set the color table to be used for the GIFs.
| ||||||||||
void |
setKeepCompletedRecordings(boolean keepCompletedRecordings)
Set whether completed recordings should be kept around for later, default is false.
| ||||||||||
void |
setOnUserIdReceivedListener(Megacool.OnUserIdReceivedListener onUserIdReceivedListener)
Use this to get the userId once it becomes available.
| ||||||||||
void |
setShareListener(Megacool.ShareListener listener)
Set the listener for share completions/dismissals.
| ||||||||||
void |
share(Activity activity)
Share the recorded GIF with link and text through the default share view with channels like
SMS, Twitter, Facebook etc.
| ||||||||||
void |
share(Activity activity, ShareConfig config)
Share the recorded GIF with link and text through the default share view with channels like
SMS, Twitter, Facebook etc.
| ||||||||||
void |
shareToMail(Activity activity)
Share the recorded GIF through a mail message
Opens an email composer view with a referral link and/or GIF, where the user can compose an email and send it to friends. | ||||||||||
void |
shareToMail(Activity activity, ShareConfig config)
Share the recorded GIF through a mail message
Opens an email composer view with a referral link and/or GIF, where the user can compose an email and send it to friends. | ||||||||||
void |
shareToMessages(Activity activity, ShareConfig config)
Share the recorded GIF through an SMS message
Opens the default SMS composer view with a referral link and/or GIF, where the user can compose a message and send it to friends. | ||||||||||
void |
shareToMessages(Activity activity)
Share the recorded GIF through an SMS message
Opens the default SMS composer view with a referral link and/or GIF, where the user can compose a message and send it to friends. | ||||||||||
void |
shareToMessenger(Activity activity)
Share the recorded GIF through Facebook Messenger
Opens a Messenger composer view with a referral link and/or GIF, where the user can compose a message and send it to friends. | ||||||||||
void |
shareToMessenger(Activity activity, ShareConfig config)
Share the recorded GIF through Facebook Messenger
Opens a Messenger composer view with a referral link and/or GIF, where the user can compose a message and send it to friends. | ||||||||||
void |
shareToTwitter(Activity activity)
Share the recorded GIF through Twitter
Opens a Twitter composer view with a referral link and/or GIF, where the user can compose a tweet and post it to their feed. | ||||||||||
void |
shareToTwitter(Activity activity, ShareConfig config)
Share the recorded GIF through Twitter
Opens a Twitter composer view with a referral link and/or GIF, where the user can compose a tweet and post it to their feed. | ||||||||||
static Megacool |
start(Context context, String appConfig)
Initialize the SDK in `onCreate` of your custom Application subclass.
| ||||||||||
static Megacool |
start(Context context, String appConfig, Megacool.OnEventsReceivedListener onEventListener)
Initialize the SDK in `onCreate` of your custom Application subclass and add a listener
for events.
| ||||||||||
static Megacool |
start(Context context, String appConfig, Megacool.OnEventsReceivedListener eventListener, String wrapper, String wrapperVersion)
Initializer dedicated for wrappers.
| ||||||||||
void |
startRecording(View view, RecordingConfig config)
Start a recording of a view with additional configuration.
| ||||||||||
void |
startRecording(View view)
Start a recording of a view.
| ||||||||||
void |
stopRecording()
Stop a recording of a view.
| ||||||||||
static void |
submitDebugData(String message)
Submit debug data to the core developers, along with a message explaining what you
expected to happen and what happened instead.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Capture a single frame of the provided View.
The captured frame is added to a buffer (default size is 50) and oldest frames will be
overwritten if the method gets called more than 50 times. The total number of frames can
be set through maxFrames(int)
. To set additional configuration for
capturing frames, use captureFrame(View, RecordingConfig)
.
This method only does anything on API level 18 and up.
view | The View you would like to record. Can be null if you're not using
the VIEW capture method.
|
---|
Capture a single frame of provided View with additional configuration.
The captured frame is added to a buffer (default size is 50) and oldest frames will be
overwritten if the method gets called more than 50 times. The total number of frames can
be set through maxFrames(int)
.
Note that even though you pass a RecordingConfig for every call to this function, only the first one has any effect, you can't modify the configuration mid-recording. You have to give a different recording identifier or stop the old recording for configuration changes to take effect.
This method only does anything on API level 18 and up.
view | The View you would like to record |
---|---|
config | Configure the recording with RecordingConfig
|
Capture a single frame of provided View with additional configuration.
The captured frame is added to a buffer (default size is 50) and oldest frames will be
overwritten if the method gets called more than 50 times. The total number of frames can
be set by calling maxFrames(int)
.
Note that even though you pass a RecordingConfig for every call to this function, only the first one has any effect, you can't modify the configuration mid-recording. You have to give a different recording identifier or stop the old recording for configuration changes to take effect.
This method only does anything on API level 18 and up.
view | The View you would like to record |
---|---|
config | Configure the recording with RecordingConfig |
forceAdd | Whether or not to ignore the BaseOverflowStrategy's decision to add the frame. This is useful for crucial moments typically at the end of the recording, to ensure a final result or score is included. Note that this is only used when the Recording is using the OverflowStrategy.TIMELAPSE capture method. |
Delete a recording
Will remove any frames of the recording in memory and on disk. Both completed and incomplete recordings will take space on disk, so if you use multiple recordingIds it's smart to free up space for new recordings
This method only does anything on API level 18 and up.
recordingId | Delete the recording with this recordingId. |
---|
Delete sent share objects that's not relevant anymore
Use the Megacool.ShareFilter
to delete specific share objects or just pass true to
delete all of them.
filter | A Megacool.ShareFilter to only delete relevant share objects.
|
---|
Get the default recording config.
Get the default share config.
Get the capture frame rate for a recording with the given id
recordingId | The recordingId of the recording |
---|
Get the Megacool singleton instance
Megacool
singleton or null if start(Context, String)
hasn't been called yet
Get the number of frames that exist for a recording with the given id
recordingId | The recordingId of the recording |
---|
Get the raw data needed to build your own preview. This is mostly useful for non-native
Android apps that can't use renderPreviewOfGif()
.
This method only returns non-null values on API level 18 and up.
recordingId | The recordingId of the recording |
---|
Get a list of the sent share objects, filtered.
Sent share objects are available so you can use their state to perform specific actions,
like showing how many shares have been sent by a user and how many that led to
INSTALLED
.
The locally cached shares will be returned immediately and are useful for determining
how many shares have been sent. If the callback is provided, the server will be queried for
an updated list of the shares. This is useful to get the latest Share#state. You
can for instance use the filter to only return a list of shares that led to
INSTALLED
and show that to the user.
callback | A Megacool.ShareCallback that gives the latest updates of the shares. |
---|---|
filter | A Megacool.ShareFilter to only retrieve relevant share objects. |
Get a list of the sent share objects.
Sent share objects are available so you can use their state to perform specific actions,
like showing how many shares have been sent by a user and how many that led to
INSTALLED
.
The locally cached shares will be returned immediately and are useful for determining
how many shares have been sent. If the callback is provided, the server will be queried for
an updated list of the shares. This is useful to get the latest Share#state.
callback | A callback that gives the latest updates of the shares |
---|
Entry point for handling links with Megacool. Usually you don't have to call this
manually, it's handled automatically if you've added the Megacool intent-filters to your
main activity and the ReferralReceiver
to your manifest as the documentation
specifies. If for some reason you can't use those, get the link that opened your
app in your own way and then call this method.
If the link is parsed successfully and is a Megacool link, a
LINK_CLICKED
event with the parsed url will be passed to your
Megacool.OnEventsReceivedListener
.
Ensure that start(Context, String, OnEventsReceivedListener)
is called before
calling this method.
url | the url that opened your app. |
---|
Wrapper for the native method mcl_init_render_thread. Used for custom engines.
Wrapper for the native method mcl_notify_render_complete. Used for custom engines. Consider this unstable
Pauses the current recording for resumption later.
The frames captured so far will be stored on disk and can be resumed later by calling
startRecording(View)
or captureFrame(View)
.
Note: If the app goes to the background, pauseRecording will automatically be called.
This method only does anything on API level 18 and up.
Used by the HighlightOverflowStrategy in order to keep track of the intensity of the game. Call this every time a significant event in the gameplay occurs, along with the amount the score changed by (optional). Score changes can be positive (biases highlight to include this event) or negative (biases highlight to not include this event)
Used by the HighlightOverflowStrategy in order to keep track of the intensity of the game. Call this every time a significant event in the gameplay occurs. With no parameters, the highlight algorithm will then select the clip where the most calls occur.
Render preview of GIF that can be showed before sharing.
Calling this method will automatically pause the recording. It assumes that
RecordingConfig#recordingId hasn't been set, if you wish to show a preview of a
specific recording, use renderPreviewOfGif(String)
instead.
This method only returns non-null values on API level 18 and up.
destroy()
Render preview of specific GIF recording that can be showed before sharing.
Calling this method will automatically pause the recording.
This method only returns non-null values on API level 18 and up.
recordingId | The recordingId of the recording |
---|
destroy()
(For testing purposes) resets the device identity, enabling it to receive events
isFirstSession()
again.
Use this if you're testing the invite flow and you want to wipe previous data from the
device. This will issue your device a new identity, which means it can receive
isFirstSession()
from
start(Context, String, OnEventsReceivedListener)
again. This enables you to
click previous links sent by the same device, mitigating the need for multiple devices to
test invites.
Note: This method should be called before
start(Context, String, OnEventsReceivedListener)
, otherwise the
changes will not have any effect until the next app session.
Set how screen captures should be performed, using a custom scale factor. Call this
as soon as possible after start(Context, String)
. Calling this more than once leads
to undefined behavior.
The default scale factor is 0.5 for screens whose longest side is < 1500 in length, or
0.25 for anything larger. If the resulting dimensions are less than 200 for either width
or height, then the scale factor is increased to ensure a minimum of 200 or more in both
dimensions (this is required for Facebook previews). By passing in a value for ScaleFactor,
you override this behavior. It's important to keep in mind that while a larger scale
factor will produce encoded media with a higher resolution, it will make captures and
encoding slower, and also increase the size of the encoded media, which will increase
both disk and network usage. In any case, we will round up the scaled dimensions to be
divisible by 16, as this is a requirement for many MP4 encoders.
The default is probably fine, this is mostly useful for non-native apps.
This method only does anything on API level 18 and up.
Set how screen captures should be performed, using the default scale factor. Call this
as soon as possible after start(Context, String)
. Calling this more than once
leads to undefined behavior.
Enables writing debug info from Megacool to logcat and saving call traces to submit to the
core developers. Useful if you're not seeing the behavior you expected and want to help us
figure out what is going wrong. Enable this before calling
submitDebugData(String)
.
Set the default recording config. This will be merged with the config given to
startRecording(View, RecordingConfig)
or
captureFrame(View, RecordingConfig)
, if any.
config | the config to use, or null to revert to the defaults. |
---|
Set the default share config. This will be merged with the config given to
share(Activity, ShareConfig)
, if any.
config | the config to use, or null to revert to the defaults. |
---|
Set the color table to be used for the GIFs.
colorTable | The color table to use for subsequent GIFs. |
---|
Set whether completed recordings should be kept around for later, default is false.
This acts as a regular disk cleanup and slight optimization if you don't intend to keep
completed recordings around to be shared later. If you do, set this to true, and use
deleteRecording(String)
to delete recordings from disk that you don't
need anymore. A completed recording will still be overwritten if a new recording is
started with the same recordingId.
keepCompletedRecordings | whether to keep completed recordings on disk |
---|
Use this to get the userId once it becomes available. Note that the onUserIdReceived(String)
method will be called on the same
thread that this method is called on, and will be called immediately if the userId is
already available.
onUserIdReceivedListener | a listener to receive the user id |
---|
Set the listener for share completions/dismissals.
Share the recorded GIF with link and text through the default share view with channels like SMS, Twitter, Facebook etc.
This method should be called after a completed recording
stopRecording()
activity | An activity used to launch the share modal |
---|
Share the recorded GIF with link and text through the default share view with channels like SMS, Twitter, Facebook etc.
This method should be called after a completed recording
stopRecording()
activity | An activity used to launch the share modal |
---|---|
config | Configuration of the share by passing a ShareConfig object
|
Share the recorded GIF through a mail message
Opens an email composer view with a referral link and/or GIF, where the user can compose an email and send it to friends.
Share the recorded GIF through a mail message
Opens an email composer view with a referral link and/or GIF, where the user can compose an email and send it to friends.
activity | an Activity used to launch the share modal |
---|---|
config | Configuration of the share by passing a ShareConfig object
|
Share the recorded GIF through an SMS message
Opens the default SMS composer view with a referral link and/or GIF, where the user can compose a message and send it to friends.
activity | an Activity used to launch the share modal |
---|---|
config | Configuration of the share by passing a ShareConfig object
|
Share the recorded GIF through an SMS message
Opens the default SMS composer view with a referral link and/or GIF, where the user can compose a message and send it to friends.
Share the recorded GIF through Facebook Messenger
Opens a Messenger composer view with a referral link and/or GIF, where the user can compose a message and send it to friends.
Share the recorded GIF through Facebook Messenger
Opens a Messenger composer view with a referral link and/or GIF, where the user can compose a message and send it to friends.
activity | an Activity used to launch the share modal |
---|---|
config | Configuration of the share by passing a ShareConfig object
|
Share the recorded GIF through Twitter
Opens a Twitter composer view with a referral link and/or GIF, where the user can compose a tweet and post it to their feed.
Share the recorded GIF through Twitter
Opens a Twitter composer view with a referral link and/or GIF, where the user can compose a tweet and post it to their feed.
activity | an Activity used to launch the share modal |
---|---|
config | Configuration of the share by passing a ShareConfig object
|
Initialize the SDK in `onCreate` of your custom Application subclass.
To register a listener for event callbacks like referrals, use
start(Context, String, OnEventsReceivedListener)
instead.
context | The Context of the Application. |
---|---|
appConfig | Your appConfig from the Megacool Dashboard as a String |
Megacool
instance, or null if invalid appConfig is given
Initialize the SDK in `onCreate` of your custom Application subclass and add a listener for events.
context | The Context of the Application. |
---|---|
appConfig | The app config from your app's dashboard. |
onEventListener | A listener that receives a List of events. There are 3 main events to handle: |
Megacool
instance, or null if invalid appConfig is given
Initializer dedicated for wrappers.
context | The Context of the Application. |
---|---|
appConfig | The app config from your app's dashboard. |
eventListener | A listener that receives a List of events. There are 3 main events to handle: |
wrapper | The name of the wrapper, ie. "Unity" or "Cocos2dx". This helps us identify issues in different wrappers and versions. |
wrapperVersion | The version of the wrapper, ie. for Unity this could be "2018.2" or "5.6". |
Megacool
instance, or null if invalid appConfig is given
Start a recording of a view with additional configuration. Call
stopRecording()
when the recording should stop.
The recording keeps a buffer of frames (default is 50). The buffer size can be set with
maxFrames(int)
. The oldest frames are overwritten until
stopRecording()
gets called.
view | The View you would like to record. Can be null if you're not using
the VIEW capture method. |
---|---|
config | Configure the recording with RecordingConfig
|
Start a recording of a view. Call stopRecording()
when the recording
should stop.
The recording keeps a buffer of frames (default is 50). The buffer size can be set with
maxFrames(int)
. The oldest frames are overwritten until
stopRecording()
gets called.
view | The View you would like to record. Can be null if you're not using the
VIEW capture method.
|
---|
Stop a recording of a view. Call this after
startRecording(View)
or multiple captureFrame(View)
.
This marks a recording as completed and it can't have any more frames added to it. Calling
startRecording(View)
or captureFrame(View)
will
overwrite the existing recording.
Submit debug data to the core developers, along with a message explaining what you
expected to happen and what happened instead. Remember to call
setDebug(boolean)
()} as early as possible in the session to capture as much
debug data as possible.