The video recording API enables you to easily add video recording to your game and let users share their videos with friends on YouTube in a few simple steps. For example, you could add a button off of a battle replay screen that when pressed would bring up the Play Games video recording experience.
This guide shows you how to implement video recording in games using the
Google Play Games Services. The APIs can be found in the
com.google.android.gms.games.video
and
com.google.android.gms.games
packages.
Before you begin
Before you start to use the video recording API:
Download and review the code sample.
Familiarize yourself with the recommendations described in the Quality Checklist.
Get the videos client
To start using the video recording API, your game must first obtain a
VideosClient
object. You can do this by calling the
Games.getVideosClient()
method and passing in the
activity and the GoogleSignInAccount
for the current player. To learn how to
retrieve the player account information, see
Sign-in in Android Games.
Video recording API basics
You can use the video recording API to integrate a video recording experience directly from within your game.
The video recording experience for users includes the following:
The video recording overlay, which has three buttons:
- Start / stop recording
- Turn on / off mic
- Turn on / off forward facing camera
A developer-provided button to initiate recording, or an alternate recording trigger
A clickable toast that pops up at the end of recording that enables players to upload the video to YouTube, or view the video through the Photos app (Note: recorded videos are stored under the category
ScreenCasts
in Photos)
Launch the video recording overlay
To initiate video recording for the currently signed-in player, follow these steps:
- Call the
VideosClient.getCaptureOverlayIntent()
method. - If the call is successful, Google Play games services returns a
Task
object which asynchronously loads an intent to launch the video recording overlay. - Use the intent from the previous step to start an activity.
Here's an example of how to bring up the video recording overlay:
private static final int RC_VIDEO_OVERLAY = 9011; public void showVideoOverlay(View myview) { Games.getVideosClient(this, GoogleSignIn.getLastSignedInAccount(this)) .getCaptureOverlayIntent() .addOnSuccessListener(new OnSuccessListener<Intent>() { @Override public void onSuccess(Intent intent) { startActivityForResult(intent, RC_VIDEO_OVERLAY); } }); }
Tips for using video recording data
The video recording API lets you integrate a video recording experience directly in your game.
Tip | Description |
---|---|
Make the video recording trigger easily discoverable |
|
Promote use of the feature in your store listing and inside the game |
|
Engage your player community with replay competitions |
|