ReplayKit は iOS 9.0 以降の特定の iPhone、iPad、iPod Touch デバイスで使用可能です。
ReplayKit allows you to record the audio and video of your game, along with user commentary through the microphone and user video through the camera. Start a recording with the StartRecording() function, and stop it with StopRecording(). You can preview the recording with the Preview() function, which launches a separate video viewer. In addition to local recordings, you can broadcast your recordings via StartBroadcasting(). There are also functions to pause, resume, and stop broadcasting.
using System; using UnityEngine; #if PLATFORM_IOS using UnityEngine.iOS; using UnityEngine.Apple.ReplayKit;
public class Replay : MonoBehaviour { public bool enableMicrophone = false; public bool enableCamera = false;
string lastError = ""; void OnGUI() { if (!ReplayKit.APIAvailable) { return; } var recording = ReplayKit.isRecording; string caption = recording ? "Stop Recording" : "Start Recording"; if (GUI.Button(new Rect(10, 10, 500, 200), caption)) { try { recording = !recording; if (recording) { ReplayKit.StartRecording(enableMicrophone, enableCamera); } else { ReplayKit.StopRecording(); } } catch (Exception e) { lastError = e.ToString(); } }
GUI.Label(new Rect(10, 220, 500, 50), "Last error: " + ReplayKit.lastError); GUI.Label(new Rect(10, 280, 500, 50), "Last exception: " + lastError);
if (ReplayKit.recordingAvailable) { if (GUI.Button(new Rect(10, 350, 500, 200), "Preview")) { ReplayKit.Preview(); } if (GUI.Button(new Rect(10, 560, 500, 200), "Discard")) { ReplayKit.Discard(); } } }
void Update() { // If the camera is enabled, show the recorded video overlaying the game. if (ReplayKit.isRecording && enableCamera) ReplayKit.ShowCameraPreviewAt(10, 350, 200, 200); else ReplayKit.HideCameraPreview(); } } #endif
APIAvailable | ReplayKit API が可能かどうかを示す boolean (True は可能を意味します)。(読み込みのみ) |
broadcastingAPIAvailable | ReplayKit の配信 API が可能かどうか示す boolean (true は可能) (読み込み専用)。 ReplayKit broadcasting API を呼び出す前にこのプロパティーの値を確認します。iOS 10 より前の iOS では、このプロパティーの値は false です。 |
broadcastURL | 配信中、または、配信済の URL にユーザーをリダイレクトする URL を含むストリングプロパティー。 |
cameraEnabled | Camera enabled status. True, if camera enabled; false otherwise. |
isBroadcasting | 現在配信中かを示す boolean プロパティーです (読み込み専用)。 |
isBroadcastingPaused | Boolean property that indicates whether a broadcast is currently paused (Read Only). |
isPreviewControllerActive | A boolean that indicates whether ReplayKit is currently displaying a preview controller. (Read Only) |
isRecording | ReplayKit がレコード中かどうかを示す boolean (True の場合はレコード中をを意味します)。(読み込みのみ) |
lastError | ReplayKit によって生じた最新のエラーを含む文字列。'Failed to get Screen Recorder (スクリーンレコーダーの取得に失敗しました)' または 'No recording available (レコードができません)' のいずれか。(読み込み専用) |
microphoneEnabled | Microphone enabled status. True, if microphone enabled; false otherwise. |
recordingAvailable | 新しいレコードがプレビュー可能かどうかを示す boolean (True は可能を意味します)。(読み込みのみ) |
Discard | 現在のレコードを破棄します。 |
HideCameraPreview | Hide the camera preview view. |
PauseBroadcasting | Pauses current broadcast. Will pause currently on-going broadcast. If no broadcast is in progress, does nothing. |
Preview | 現在のレコードをプレビューします。 |
ResumeBroadcasting | Resumes current broadcast. Will resume currently on-going broadcast. If no broadcast is in progress, does nothing. |
ShowCameraPreviewAt | Shows camera preview at coordinates posX and posY. The preview is width by height in size. |
StartBroadcasting | Initiates and starts a new broadcast When StartBroadcast is called, user is presented with a broadcast provider selection screen, and then a broadcast setup screen. Once it is finished, a broadcast will be started, and the callback will be invoked. It will also be invoked in case of any error. |
StartRecording | レコードを開始します。 |
StopBroadcasting | Stops current broadcast. Will terminate currently on-going broadcast. If no broadcast is in progress, does nothing. |
StopRecording | 現在のレコードを停止します。 |
BroadcastStatusCallback | 配信用 API の起動の完了時に呼び出される関数。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.