-
Notifications
You must be signed in to change notification settings - Fork 1
Capturing & Sharing
Before you start your recording session, make sure that current device is supporting the ReplayKit.
using SA.iOS.ReplayKit;
...
bool isAvailable = ISN_RPScreenRecorder.IsAvailable;
Starts recording the app display using the StartRecording method of ISN_RPScreenRecorder class. When the StartRecording method is first called, an alert window appears asking the user to confirm recording. This alert window is also presented if it has been longer than 8 minutes since the last time StartRecording method was called.
See the example:
using SA.iOS.ReplayKit;
...
ISN_RPScreenRecorder.StartRecording((result) => {
if(result.IsSucceeded) {
Debug.Log("Scrren recodring is started");
} else {
Debug.Log("User decalied screen recording request");
}
When you are ready to finish recording use StopRecording method to stop the current recording. When recording stops and there is no error associated with the recording, present the resulting preview view controller using ISN_RPPreviewViewController. The user will see the built-in preview view controller, providing them with the option to trim, cut, and share the recording. On the iPad, the preview view controller will be presented as a popover.
Stop result is represented as ISN_RPStopResult class. if anything at all was recorded result will hold the ISN_RPPreviewViewController instance, that you can use to present built-in preview view controller for managing recorded video. You can always subscribe to the ISN_RPPreviewViewController preview result that is represented as ISN_PRPreivewResult, that will hold an ActivityTypes List, the user used to save or share a video. If array comes empty, it means a user just skipped interaction with video.
See the full example below:
using SA.iOS.ReplayKit;
...
ISN_RPScreenRecorder.StopRecording((result) => {
if(result.HasPreviewController) {
result.PreviewController.Present((prevewResult) => {
if(prevewResult.IsSucceeded) {
Debug.Log("User Saved video");
foreach(string activity in prevewResult.ActivityTypes) {
Debug.Log("Video was shared to: " + activity);
}
}
});
}
});
Screen recording can be unavailable due to unsupported hardware, the user’s device displaying information over Airplay or through a TVOut session, or another app using the shared recorder. The DidChangeAvailability event can be used to Indicates that the recorder has changed states between disabled and enabled.
ISN_RPScreenRecorder.DidChangeAvailability.AddListener(() => {
Debug.Log("Replay Kit avalibility has chnaged:");
Debug.Log("Replay Kit avaliable: " + ISN_RPScreenRecorder.IsAvailable);
});
The DidStopRecording notification is generated is when recording stops due to an error or a change in recording availability. If any part of the stopped recording is available, an instance of ISN_RPStopResult is returned. In other words, you handle this event the same way you handle StopRecording method result
using SA.iOS.ReplayKit;
...
ISN_RPScreenRecorder.DidStopRecording.AddListener((result) => {
if (result.HasPreviewController) {
result.PreviewController.Present((prevewResult) => {
if (prevewResult.IsSucceeded) {
Debug.Log("User Saved video");
foreach (string activity in prevewResult.ActivityTypes) {
Debug.Log("Video was shared to: " + activity);
}
}
});
}
});
Reliable and high-quality Unity Development service. Let's Talk!
Website | AssetStore | LinkedIn | Youtube | Scripting Reference
- Getting Started
- Authentication
- Game Center UI
- Leaderboards
- Default Leaderboard
- Achievements
- Saving A Game
- Access Point
- iTunes Connect Setup
- StoreKit Initialization
- Purchase flow
- Receipt Validation
- Store Review Controller
- Storefront API
- Subscription Offers