Skip to content

Instantly share code, notes, and snippets.

@manwithsteelnerves
Created October 9, 2020 18:01
Show Gist options
  • Save manwithsteelnerves/f7e8b2fa0265478effc907e796cf6b43 to your computer and use it in GitHub Desktop.
Save manwithsteelnerves/f7e8b2fa0265478effc907e796cf6b43 to your computer and use it in GitHub Desktop.
private void OnEnable()
{
ReplayKitManager.DidRecordingStateChange += DidRecordingStateChange;
}
private void OnDisable()
{
ReplayKitManager.DidRecordingStateChange += DidRecordingStateChange;
}
public void StopRecording()
{
if (ReplayKitManager.IsRecording())
{
ReplayKitManager.StopRecording();
}
}
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");
ReplayKitManager.SavePreview((error) =>
{
SetStatus("Saved preview to gallery with error : " + ((error == null) ? "null" : error));
textMessage.SetActive(true);
});
break;
default:
Debug.Log("Unknown State");
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment