录屏分享系统

来自AnySDK 文档
跳转至: 导航搜索
录屏分享类SDK针对手游录像和快速分享提供了一整套的解决方案。支持基于OpenGL ES的游戏引擎,比如Cocos2d-x、 Unity3d 以及其它的游戏引擎。

相关接口

设置录屏分享回调监听

分享系统存在回调信息,需要设置监听。

_instance = AnySDKREC.getInstance ();
_instance .setListener (this,"RECExternalCall");
void RECExternalCall(string msg)
{
    Debug.Log("RECExternalCall("+ msg+")");
    Dictionary<string,string> dic = AnySDKUtil.stringToDictionary (msg);
    int code = Convert.ToInt32(dic["code"]);
    string result = dic["msg"];
    switch(code)
    {
    case (int)RECResultCode.kRECInitSuccess://初始化成功
        Debug.Log("kRECInitSuccess\n");
        break;
    case (int)RECResultCode.kRECInitFail://初始化失败
        Debug.Log("kRECInitFail\n");
        break;
    case (int)RECResultCode.kRECStartRecording://开始录制
        Debug.Log("kRECStartRecording \n");
        break;
    case (int)RECResultCode.kRECStopRecording://结束录制
        Debug.Log("kRECStopRecording \n");
        break;
    case (int)RECResultCode.kRECPauseRecording://暂停录制
        Debug.Log("kRECPauseRecording \n");
        break;
    case (int)RECResultCode.kRECResumeRecording://恢复录制
        Debug.Log("kRECResumeRecording \n");
        break;
    case (int)RECResultCode.kRECEnterSDKPage://进入SDK页面
        Debug.Log("kRECEnterSDKPage \n");
        break;
    case (int)RECResultCode.kRECQuitSDKPage://退出SDK页面
        Debug.Log("kRECQuitSDKPage \n");
        break;
    case (int)RECResultCode.kRECShareSuccess://视频分享成功
        Debug.Log("kRECShareSuccess \n");
        break;
    case (int)RECResultCode.kRECShareFail://视频分享失败
        Debug.Log("kRECShareFail \n");
        break;
    default:
        break;
    }
}

开始录制

void startRecording();

接口说明:

开始视频录制

范例

_instance = AnySDKREC.getInstance ();
_instance.startRecording();

结束录制

void stopRecording();

接口说明:

结束视频录制

范例

_instance = AnySDKREC.getInstance ();
_instance.stopRecording();

分享

void share(std::map<std::string, std::string> info;);

接口说明:

分享

参数信息:

参数 参数说明
Video_Title 视频标题
Video_Desc 视频描述

范例

_instance = AnySDKREC.getInstance ();
Dictionary<string,string> info = new Dictionary<string, string>();
info["Video_Title"] = "AnySDK";
info["Video_Desc"] = "AnySDK是一个神奇的SDK";
AnySDKREC.getInstance().share(info);

扩展函数

暂停录制

void pauseRecording();

接口说明:

暂停视频录制

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "pauseRecording" ) ) 
{
    _instance.callFuncWithParam( "pauseRecording" );
}

恢复录制

void resumeRecording();

接口说明:

恢复视频录制

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "resumeRecording" ) ) 
{
    _instance.callFuncWithParam( "resumeRecording" );
}

设备是否支持录制

bool isAvailable();

接口说明:

判断设备是否支持,支持返回ture,否则返回false

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "isAvailable" ) ) 
{
    return _instance.callBoolFuncWithParam( "isAvailable" );
}

获取录制状态

bool isRecording();

接口说明:

当前视频是否正在录制,true:正在录制,false:未录制

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "isRecording" ) ) 
{
    return _instance.callBoolFuncWithParam( "isRecording" );
}

显示工具条

void showToolBar();

接口说明:

显示工具条界面

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "showToolBar" ) ) 
{
    _instance.callFuncWithParam( "showToolBar" );
}

隐藏工具条

void hideToolBar();

接口说明:

隐藏工具条界面

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "hideToolBar" ) ) 
{
    _instance.callFuncWithParam( "hideToolBar" );
}

显示视频中心

void showVideoCenter();

接口说明:

显示视频中心

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "showVideoCenter" ) ) 
{
    _instance.callFuncWithParam( "showVideoCenter" );
}

显示平台中心

void enterPlatform();

接口说明:

进入平台中心

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "enterPlatform" ) ) 
{
    _instance.callFuncWithParam( "enterPlatform" );
}

设置视频相关数据

void setMetaData(std::map<string,string> data);

接口说明:

设置视频相关数据,建议先检查是否是正在录制

范例

_instance = AnySDKREC.getInstance ();
if( _instance.isFunctionSupported( "setMetaData" ) ) 
{
    Dictionary<string, string> data = new Dictionary<string, string>();
    data["ext"] = "anysdk";
    AnySDKParam param = new AnySDKParam(data);
    _instance.callFuncWithParam( "setMetaData",param );
}