Did Recording State Change

We can receive the recording state changes by listening to DidRecordingStateChange event. The event informs about the current status(ReplayKitRecordingState) of the recording.

Status

Description

ReplayKitRecordingState.Started

Status returned when video recording starts

ReplayKitRecordingState.Stopped

Status returned when video recording stops

ReplayKitRecordingState.Failed

Status returned when video recording fails to record

ReplayKitRecordingState.Available

Status returned when Video Recording is available for Preview

Registering to the event

ReplayKitManager.DidRecordingStateChange += DidRecordingStateChange;

De-Registering to the event

ReplayKitManager.DidRecordingStateChange -= DidRecordingStateChange;

Example

void OnEnable()
{
// Register to the events
ReplayKitManager.DidInitialise += DidInitialise;
ReplayKitManager.DidRecordingStateChange += DidRecordingStateChange;
}
void OnDisable()
{
// Deregister the events
ReplayKitManager.DidInitialise -= DidInitialise;
ReplayKitManager.DidRecordingStateChange -= DidRecordingStateChange;
}
private void DidRecordingStateChange(ReplayKitRecordingState state, string message)
{
Debug.Log("Received Event Callback : DidRecordingStateChange [State:" + state.ToString() + " " + "Message:" + message);
switch(state)
{
case ReplayKitRecordingState.Started:
Debug.Log("ReplayKitManager.DidRecordingStateChange : Video Recording Started");
break;
case ReplayKitRecordingState.Stopped:
Debug.Log("ReplayKitManager.DidRecordingStateChange : Video Recording Stopped");
break;
case ReplayKitRecordingState.Failed:
Debug.Log("ReplayKitManager.DidRecordingStateChange : Video Recording Failed with message [" + message+"]");
break;
case ReplayKitRecordingState.Available:
Debug.Log("ReplayKitManager.DidRecordingStateChange : Video Recording available for preview");
break;
default:
Debug.Log("Unknown State");
break;
}
}
private void DidInitialise(ReplayKitInitialisationState state, string message)
{
Debug.Log("Received Event Callback : DidInitialise [State:" + state.ToString() + " " + "Message:" + message);
switch (state)
{
case ReplayKitInitialisationState.Success:
Debug.Log("ReplayKitManager.DidInitialise : Initialisation Success");
break;
case ReplayKitInitialisationState.Failed:
Debug.Log("ReplayKitManager.DidInitialise : Initialisation Failed with message["+message+"]");
break;
default:
Debug.Log("Unknown State");
break;
}
}