reK – ReplayKit Plugin for iOS

Overview

reK – ReplayKit Plugin for iOS enables you to integrate video recording functionality into your Unity iOS game within a matter of minutes.

Starting with version 1.4, reK also supports ReplayKit Live, and thus provides support for live streaming and broadcasting to services such as Mobcrush or Periscope. See below for more information on how to integrate this into your game.

Available on the Asset Store

Unity Asset Store

Support

If you have questions, do not hesitate to contact us directly: rek@rarebyte.com

There is also a Unity forum thread available.

Microphone Support

reK – ReplayKit Plugin for iOS supports using the device’s microphone to record additional audio which is great for let’s play videos.

Camera Support

reK – ReplayKit Plugin for iOS supports using the device’s camera to record video from the front camera. A small picture-in-picture view is added to your game if you selected this option.

Important: If you use the camera or microphone in your game, you will need to add the corresponding usage descriptions in your iOS build settings:

rek_usage_descriptions

Integration: Native iOS Overlay

Example scene: UnityReplayKitExamples/UnityReplayKitExampleNativeOverlay

The easiest way to integrate reK – ReplayKit Plugin for iOS is as simple as that:

  • Drag and drop the unity_replay_kit prefab into your scene.
  • Done!

By default, the option Native iOS Overlay is already selected. The following options are available:

  • Anchor: Defines the position of the native widget
  • Offset (if not using anchor Custom): Relative position to the anchor
  • Position (if using anchor Custom): Absolute position of the widget
  • Auto-scale widget: Whether the native widget should be scaled automatically depending on the device’s screen height
  • Size (either in percent or in pixels, depending on the auto-scale setting): The size of the native widget

There is also preview of the recording controls widget available in the game view of Unity that reflects all parameter changes immediately.

A big advantage of the Native iOS Overlay is that the recording widget itself is not recorded to your video.

rek_screenshot04

Integration: Custom

If you do not want to use the Native iOS Overlay method, just set the mode to Custom. The package includes examples for both Unity UI and NGUI (which is still used by a lot of developers). Additionally, we included an code-only example (using the legacy OnGUI system).

Unity UI

Example scene: UnityReplayKitExamples/UnityReplayKitExampleUnityUI

NGUI

To use the NGUI example, you need to import UnityReplayKitNGUIExample.unitypackage in UnityReplayKit/Examples, and – of course – you need to have NGUI imported.

Example scene: UnityReplayKitNGUI/UnityReplayKitExampleNGUI

Code-Only

As a reference, take a look at the example scene UnityReplayKitExamples/UnityReplayKitExampleOnGui

In some games it is very useful to record complete runs (e.g. in an endless runner) and provide players the option to either edit/share the video at the end of the run. In order to do that the recording can be started and stopped automatically via code:

// the run/game starts, start recording
UnityReplayKit.Instance.StartRecording();

// ...

// the run/game ends, stop recording
UnityReplayKit.Instance.StopRecording();

// present the video edit/preview window to the player
UnityReplayKit.Instance.ShowPreview();

You can also use actions to react to what’s happening with your recordings, e.g.:

UnityReplayKit.Instance.Started += () => Debug.Log("Recording has started");

The actions available are:

// triggered if the recording cannot be started (e.g. because disk is full)
public Action<ReplayKitError> StartFailed;

// triggered after the recording has been started
public Action Started;

// triggered if stopping the recording has failed
public Action<ReplayKitError> StopFailed;

// triggered after the recording has been stopped
public Action Stopped;

// triggered after a recording has been discarded
public Action Discarded;

// triggered after the user has completed interaction with the native preview
public Action PreviewCompleted;

// called just before starting the recording
public Action PreStart;

// called just before stopping the recording
public Action PreStop;

// called just before displaying the preview dialog
public Action PreShowPreview;

// called just before discarding a recording
public Action PreDiscard;

Compatibility

reK – ReplayKit Plugin for iOS depends on Apple’s ReplayKit framework that has the following requirements:

  • iOS version: 9 or higher
  • Supported CPUs: A7, A8 or higher

Important: If you need your game to run on older versions of iOS, you need to set the ReplayKit framework dependency to Optional in the Build Phases settings in your Xcode project, just like in this screenshot:

rek_replaykit_optional

You can also check if ReplayKit is available by using the IsReplayKitAvailable property like this:

if(UnityReplayKit.Instance.IsReplayKitAvailable) {
  // available
} else {
  // not available, e.g. hide buttons etc.
}

Integrating Live Streaming/Broadcasting Support

Using reK you can add live streaming/broadcasting support to your game. It supports all third party applications that provide a Broadcast UI extension. In the game, players would have to perform these tasks to start a broadcast:

  • Select a broadcast service (e.g. Mobcrush) via the native iOS broadcast service selection dialog
  • Configure broadcast service options (dialog coming directly from the broadcasting app), e.g. enter an epic title for the broadcast
  • Start streaming

Some services also support a pause/resume functionality which can also be accessed via reK.

Integration reK live streaming into your game is very easy. Take a look at the example scene UnityReplayKitExampleBroadcasting. All you have to do is drag the unity_replaykit prefab into your scene, set it to Custom (unless you also want the native recording UI available as described above).

To let the user select a broadcasting service, just call the following method via code or wire up a button with:

UnityReplayKit.Instance.SelectBroadcastingService();

After the user has selected and configured the broadcasting service, start broadcasting with:

UnityReplayKit.Instance.StartBroadcast();

To stop the broadcast, just call:

UnityReplayKit.Instance.StopBroadcast();

There are some callbacks from the plugin that are quite useful:

// Is called just after a broadcast service has been selected
public Action BroadcastServiceSelected;

// Is called when the broadcast service selection has failed
public Action<ReplayKitError> BroadcastServiceSelectionFailed;

// Is called just after broadcasting has started successfully
public Action BroadcastStarted;

// Is called when the broadcast has failed to start
public Action<ReplayKitError> BroadcastStartFailed;

// Is called just after the broadcast has initiated stopping successfully
public Action BroadcastStopped;

// Is called when trying to stop the broadcast has failed
public Action<ReplayKitError> BroadcastStopFailed;

// Is called just after the broadcast has been finished
public Action BroadcastFinished;

// Is called when finishing the broadcast has failed
public Action<ReplayKitError> BroadcastFinishFailed;

You can easily add your custom code to those actions like this:

UnityReplayKit.Instance.BroadcastServiceSelected += () => Debug.Log("Broadcast service selected");
UnityReplayKit.Instance.BroadcastServiceSelectionFailed += (error) => Debug.Log("Broadcast selection failed: " + error.ToString());

 

42 thoughts on “reK – ReplayKit Plugin for iOS”

  1. Hi Carl,

    The asset is currently in review at Unity and will be available soon/within the next few days. The plugin was submitted with the latest Unity version, but should be working with older versions as well.

    If you need more info or have questions, drop us a line and we will be happy to answer them.

  2. Does this asset show a messaage when you start recording? I want to use it to record video for a video making app. I saw a popup appears in all replaykit samples, asking if a user wants to record microphone. With your asset :
    1. Can I not ahve that message (just have a message for permission, NOT asking IF).
    2. Can I record the videos to a location where I can do whatever I want with them? (e.g. I can then deal with them programatically)

  3. Hi George,

    thanks for your comment! The message that pops up asking the user if she/he wants to allow recording is an iOS permission thing, but is only shown the first time a recording is started for an app. Concerning your questions:
    1. You cannot remove this permission dialog since it comes from the OS (but is only shown once/the first time you start recording).
    2. After the recording is done, you can show a preview to the user and the user is able to edit and share the video. Sharing options depend on what is installed on the device – default options are save to videos, mail; if apps like Facebook or WhatsApp are installed, those are available, too). It is not possible to save videos programmatically without letting the user know.

    We would be happy to answer any further questions, just drop us a line!

  4. Hi,

    How do I exclude my OnGui elements from being recorded ? Have looked at UnityReplayKitExampleGameOnGui but to me it isn’t obvious ?

    In my experience I get the message pop up asking for permission, every time I start the app, is there no way for the app to remember the permission ?

    Thanks!

  5. Hi,

    use the Native iOS Overlay (can be configured on the prefab) if you don’t want record controls to be recorded.

    The permission popup should not popup every time in production apps. During development, it could happen more often because the app is being reinstalled/updated. Maybe that is the issue?

    Please let us know if you have further questions!

  6. On iphone6 black screen, iphon5s the first screen recording is very slow, how to solve it?

  7. Thanks for your comment, here are a few questions:
    – Do our example scenes work on your devices?
    – Do you have enough disk space on the devices?
    – iPhone 6: Does it record a black screen at the beginning (e.g. flickering) or is the whole recording just black?
    – iPhone 5S: By slow, do you mean that it stutters/loses frames?
    – How is the overall framerate of your game?

  8. – your example have the same problem.
    -yes i have enough disk (free 8G).
    -iPhone6 is recording just black.
    -yes it stutters/loses frames.
    -about 60fps.

  9. Hi Nick,

    The plugin enables streaming to all apps that provide a iOS sharing extension for video streams. Concerning Twitch, as far as I know, they do not support it yet. In contrast, other services such as Mobcrush or Periscope, do.

  10. Just buy it and it works very well, I have two questions…

    1- How do I change the alert message? You can save the recording to the camera roll or share.. etc … (because I need it custom in Spanish)
    2- can i disable the 2 option? i just need 1 “Record Screen & Microphone”

  11. 1 – Unfortunately, this popup/alert comes directly from iOS and they have not localized it yet. It is not possible to change that at the moment, we will have to wait for an update from Apple.

    2 – The popup/permission alert cannot be disabled because it is required by iOS. However, the options presented depend on what features you have selected (microphone, camera).

  12. You cannot hide any elements that are inside the application’s main window (which is the window Unity renders to). That’s why the plugin has a native UI on top in a separate window. At the moment, you can customize the native recording controls by setting its position, but you cannot add other controls to that window. In order to do that, you need to add your own separate native UI window.

  13. thank you charlie

    Has anyone solved the bug audio on facebook?

    Videos with comments made with the microphone are mute when they are shared on facebook / youtube

  14. When you record with commentary, what happens is that there ReplayKit records two separate audio tracks (one is game audio, the other one is the microphone), which actually makes sense. However, the Facebook sharing extension seems unable to handle that properly and does not merge those audio tracks or completely ignore them. What you could play around with is using the MicrophoneLoopback stuff that’s coming with reK (we do use that for live streaming as well), as this will play the microphone back within in the game.

  15. I am not sure how to use this function, I am not that good in C# … in which file I include it? In which line?

  16. We have just replied to your email. We will probably add a checkbox to the prefab for microphone loopback support for recordings in one of the next updates, so that’s easier to use for everyone.

  17. Hello,

    I wanted an option where a screen recording is automatically saved to the camera roll on stop-recording.
    I am not able to do that currently.
    Is that a limitation of the plugin or is that a platform limitation?

    Regards,
    Saif

  18. Hello Saif,

    This is a platform limitation. Apple wants the user to be in control of that, so we can only bring up the preview dialog that also contains the sharing options. There is currently no way to save it to camera roll automatically.

  19. Hello,

    How to add another item (like text, timer etc.) for overlay screen?
    Actually I want a timer on screen while recording.

    Regards,
    Saif

  20. Hello Saif,

    At the moment you cannot add custom controls to the overlay. You can however, implement your own native window on top that does that. We haven’t decided on a way to handle additional custom controls (there were some requests, but all of them pretty special, and there is currently no generic way of adding those). If you have specific requirements, we could also build a custom tailored version for you, please send your infos/requirements to rek@rarebyte.com – thanks!

  21. I just want it to solve the audio problem …
    (when a video shares a facebook or youtube there is no audio from the microphone)

  22. Hi Guillermo,

    Unfortunately, this is a problem related to those sharing extensions (which are developed by Facebook, and YouTube, respectively). ReplayKit records audio into to separate tracks, one being game audio, and the other being your commentarey (microphone). The sharing extension would need to merge those tracks into one before uploading. So I am afraid we can’t do anything about this at the moment, but you can still save your recording to camera roll and then copy it to a desktop machine for further processing.

  23. Hi Charlie. I have some questions before buy your plugin. Please, can you answer them?:

    1 – I want to start / stop recording with Code-Only, and I want to show the recording widget only to indicate that the app is recording. But the widget should not be interactive (the user cannot stop recording). Can I do it with your widget?

    2 – If the user deny record permission in the dialog shown, then is the StartFailed event fired?

    3 – Do you include source code?

    Thanks.

  24. Can you not just mix the two audio tracks together on the fly as default?
    Considered purchasing this, but now I will be on the fence til this is fixed,…

  25. To answer the last couple of questions:

    >> 1 – I want to start / stop recording with Code-Only, and I want to show the recording widget only to indicate that the app is recording. But the widget should not be interactive (the user cannot stop recording). Can I do it with your widget?

    Of course you can start/stop recording only using code, but the native overlay button currently does not have a read-only mode. I will add this to our list of things to consider for one of the next updates.

    >> 2 – If the user deny record permission in the dialog shown, then is the StartFailed event fired?
    Yes, and there should be the corresponding error code saying that the user denied access.

    >> 3 – Do you include source code?
    C# code is included, native plugin code is not included.

    >> Can you not just mix the two audio tracks together on the fly as default?
    >> Considered purchasing this, but now I will be on the fence til this is fixed,…
    We are investigating this, not sure if it is possible yet.

    >> Hey I was wondering is it possible to change the native recording controls image textures?
    Not possible at the moment, as the native recording controls do not use textures, they are drawn directly (making them pixel-perfect for all resolutions).

  26. Hello
    Thanks for your rek. I like the video recording tool. Then I have a question. Can I store the recorded video in the camera roll? For example, after click stop record button, the user select save button and then store the video in the camera roll. Is this possible current version or maybe? Thanks

  27. Hi, Charlie. I have got satisfied the results. And then I have a got a bit issue. After start record, it is pop up alert message – “Allow screen recording in “—“”. If I select “Record Screen Only” option, it is working well. But select “Record Screen & Camera”, camera(face camera) is not working(it is crash). So now I need only “Record Screen only” option. In other words, I want remove “Record Screen & Camera” option into alert message. What should I do?

Leave a Reply

Your email address will not be published. Required fields are marked *