Table of Contents

Class Recorder

命名空間
easyar

Recorder 實現了對當前渲染環境的螢幕錄製功能。 當前Recorder 只在 Android(4.3 或更新)和 iOS的OpenGL ES 3.0 環境下工作。 由於依賴於OpenGLES,本類的所有函數(除requestPermissions以外,包括析構函數)都必須在單個包含OpenGLES上下文的線程中調用。 Unity Only Unity中如果使用Multi-threaded rendering功能,則腳本線程將與渲染線程分離,無法在渲染線程上調用updateFrame。因此,如果需要使用螢幕錄製功能,應禁用Multi-threaded rendering功能。 Android使用時需要在AndroidManifest.xml中加入android.permission.RECORD_AUDIO權限聲明。 iOS使用時需要在Info.plist中加入NSMicrophoneUsageDescription權限聲明。

Recorder

方法

isAvailable

只在Android 4.3以上或iOS平台下返回true。

bool easyar_Recorder_isAvailable(void)
static bool isAvailable()
public static boolean isAvailable()
companion object fun isAvailable(): Boolean
+ (bool)isAvailable
public static func isAvailable() -> Bool
public static bool isAvailable()

傳回值

類型 描述
Boolean

requestPermissions

請求錄屏所需的系統權限。你可以選擇使用這個函數或自己調用系統函數申請權限。只在Android和iOS平台上有效,其他平台上的行為為直接調用回調通知權限已授權。應在UI線程調用該函數。

void easyar_Recorder_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)
static void requestPermissions(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(PermissionStatus, std::string)>> permissionCallback)
public static void requestPermissions(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromPermissionStatusAndString permissionCallback)
companion object fun requestPermissions(callbackScheduler: CallbackScheduler, permissionCallback: FunctorOfVoidFromPermissionStatusAndString?): Unit
+ (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback
public static func requestPermissions(_ callbackScheduler: CallbackScheduler, _ permissionCallback: ((PermissionStatus, String) -> Void)?) -> Void
public static void requestPermissions(CallbackScheduler callbackScheduler, Optional<Action<PermissionStatus, string>> permissionCallback)

參數

名稱 類型 描述
callbackScheduler CallbackScheduler
permissionCallback Optional<Action<PermissionStatus,String>>

傳回值

類型 描述
Void

create

創建並初始化錄屏功能。statusCallback回調中會通知一些狀態變化和對應的日誌。

void easyar_Recorder_create(easyar_RecorderConfiguration * config, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromRecordStatusAndString statusCallback, easyar_Recorder * * Return)
static std::shared_ptr<Recorder> create(std::shared_ptr<RecorderConfiguration> config, std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(RecordStatus, std::string)>> statusCallback)
public static @Nonnull Recorder create(@Nonnull RecorderConfiguration config, @Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromRecordStatusAndString statusCallback)
companion object fun create(config: RecorderConfiguration, callbackScheduler: CallbackScheduler, statusCallback: FunctorOfVoidFromRecordStatusAndString?): Recorder
+ (easyar_Recorder *)create:(easyar_RecorderConfiguration *)config callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler statusCallback:(void (^)(easyar_RecordStatus status, NSString * value))statusCallback
public static func create(_ config: RecorderConfiguration, _ callbackScheduler: CallbackScheduler, _ statusCallback: ((RecordStatus, String) -> Void)?) throws -> Recorder
public static Recorder create(RecorderConfiguration config, CallbackScheduler callbackScheduler, Optional<Action<RecordStatus, string>> statusCallback)

參數

名稱 類型 描述
config RecorderConfiguration
callbackScheduler CallbackScheduler
statusCallback Optional<Action<RecordStatus,>>

傳回值

類型 描述
Recorder

start

開始錄屏。

void easyar_Recorder_start(easyar_Recorder * This)
void start()
public void start()
fun start(): Unit
- (void)start
public func start() -> Void
public virtual void start()

傳回值

類型 描述
Void

updateFrame

使用texture錄製一幀數據。

void easyar_Recorder_updateFrame(easyar_Recorder * This, easyar_TextureId * texture, int width, int height)
void updateFrame(std::shared_ptr<TextureId> texture, int width, int height)
public void updateFrame(@Nonnull TextureId texture, int width, int height)
fun updateFrame(texture: TextureId, width: Int, height: Int): Unit
- (void)updateFrame:(easyar_TextureId *)texture width:(int)width height:(int)height
public func updateFrame(_ texture: TextureId, _ width: Int32, _ height: Int32) -> Void
public virtual void updateFrame(TextureId texture, int width, int height)

參數

名稱 類型 描述
texture TextureId
width Int32
height Int32

傳回值

類型 描述
Void

stop

停止錄屏。在調用stop之後,會等待文件寫入結束並返回錄製是否成功的結果。

bool easyar_Recorder_stop(easyar_Recorder * This)
bool stop()
public boolean stop()
fun stop(): Boolean
- (bool)stop
public func stop() -> Bool
public virtual bool stop()

傳回值

類型 描述
Boolean