400-881-9892

文档中心

官方文档,可查阅产品介绍、快速入门、用户指南、开发指南、API参考、SDK参考、帮助等信息。

文档中心 互动课堂

Server Recording And Local Recording

    startServerRecord
    • A brief description - Start server recording

    We provide a course recording feature that can fully reproduce the teaching process. Calling this interface can record the course. - After recording is started, the callback is: the callback of the recording status - (void)onRoomServerRecordStateChange(TK_RECORD_STATE state, String userId, String mp4RecordId, String commonRecordId);

    • Interface Name

    - (int)startServerRecord(Map<String, Object> recordParams, long expiresabs, long expires);

    • Parameters
    Parameter Name Required Type Description
    recordParams Yes Map Recording parameters include two recording modes: standard and mix. For details, see the method example
    expiresabs Yes long Recording duration, 0: indicates no time limit, until the stop recording call is made
    expires Yes long The timestamp when recording ends, 0: indicates that no end time is set
    • Method Example
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    //---------------standard mode---------//
    //standard mode is the standard and regular recording mode, which is the default mode 
    Map<String, Object> recordParams = new HashMap<String, Object>();
    recordParams.put("recordMode",SERVER_RECORD_MODE.STANDARD);
    TKRoomManager.getInstance().startServerRecord(recordParams,0,0);
     
    //--------------- mix mode ------------//
    //mix mode is for custom mixed stream recording, and the following parameters need to be passed in
    Map<String, Object> recordParams = new HashMap<String, Object>();
    recordParams.put("recordMode",SERVER_RECORD_MODE.MIX);
    //mix parameters 
    Map<String, Object> mixStreamParams = new HashMap<String, Object>();
    // required, mixed stream layout template ID, 0 for equal distribution layout; 1 for picture-in-picture layout; 2 for custom layout
    mixStreamParams.put("template",0);
    // color value 
    mixStreamParams.put("backgroundColor","#0d69fb");
    //custom parameters 
    Map<String, Object> customConfigParams = new HashMap<String, Object>();
    // after starting the mixed stream, if there is no stream of the specified users in the room, the mixed stream will stop after 30 seconds 
    customConfigParams.put("noStreamTimeout_s",30);
    // for compatibility, if specified, the priority is higher than the outer background color configuration 
    customConfigParams.put("backgroundColor","#0d69fb");
    //custom style set 
    List<Map<String,Object>> videoLayoutList = new ArrayList<>();
    //the style of a certain user 
    Map<String,Object> videoLayoutUser = new HashMap<>();
    //// user ID, if it is the video of desktop sharing, this ID is &#039;user ID:screen&#039;
    videoLayoutUser.put("uid","xxx");
    // window x-coordinate, the value is the percentage relative to the entire video width 
    videoLayoutUser.put("x_coord",0.81);
    // window y-coordinate, the value is the percentage relative to the entire video height 
    videoLayoutUser.put("y_coord",0.1);
    // window width, the value is the percentage relative to the entire video width 
    videoLayoutUser.put("width",0.18);
    // window height, the value is the percentage relative to the entire video height 
    videoLayoutUser.put("height",0.24);
    // window transparency 
    videoLayoutUser.put("alpha",1);
    // default value true;true:display the video window,false:do not display the video window 
    videoLayoutUser.put("play_video",true);
    // default value true;true:play audio,false:do not play audio 
    videoLayoutUser.put("play_audio",true);
    videoLayoutList.add(videoLayoutUser);
    customConfigParams.put("videoLayout",videoLayoutList);
    mixStreamParams.put("customConfig",customConfigParams);
    recordParams.put("mixStreamParams",mixStreamParams);
    TKRoomManager.getInstance().startServerRecord(recordParams,0,0);
    
    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    stopServerRecord
    • A brief description - Stop server recording

    • Interface Name

    - (int)stopServerRecord();

    • Method Example

    TKRoomManager.getInstance().stopServerRecord();

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    pauseServerRecord
    • A brief description - Pause server recording

    • Interface Name

    - (int)pauseServerRecord();

    • Method Example

    TKRoomManager.getInstance().pauseServerRecord();

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    resumeServerRecord
    • A brief description - Resume server recording

    • Interface Name

    - (int)resumeServerRecord();

    • Method Example

    TKRoomManager.getInstance().resumeServerRecord();

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    startAudioRecording
    • A brief description - Start local audio recording

    It will record all the sound data in the room and then save it to the sandbox.

    • Interface Name

    - (int)startAudioRecording(String filePath);

    • Parameters
    Parameter Name Required Type Description
    filePath Yes String The path where the recording file is saved must be a valid sandbox file path, such as xxx/Library/Caches/audioRecord.mp3. Note:1.  The audio file is saved in MP3 format; 2.  If the same path is passed in twice, the recording data will be overwritten; 3.  The file path must be a valid path, otherwise the recording will fail. For example, if the path does not exist or is not a file path (but a folder path), the recording will fail.
    • Method Example

    TKRoomManagerImpl.getInstance().startAudioRecording(filePath);

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    pauseAudioRecording
    • A brief description - Whether to pause audio recording

    It will record all the sound data in the room and then save it to the sandbox.

    • Interface Name

    - (int)pauseAudioRecording(boolean isPause);

    • Parameters
    Parameter Name Required Type Description
    isPause Yes boolean Whether to pause recording
    • Method Example

    TKRoomManager.getInstance().pauseAudioRecording(false);

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    stopAudioRecord
    • A brief description - Stop local audio recording

    • Interface Name

    - (int)stopAudioRecording();

    • Method Example

    TKRoomManagerImpl.getInstance().stopAudioRecording();

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure