400-881-9892

文档中心

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

文档中心 互动课堂

Share And Play Media Stream

    startShareMedia
    • A brief description - Publish media stream file

    The media stream file must have been uploaded to the server. You can listen to notifications via TKRoomManagerObserver. After entering the room, the SDK will notify all users in the room of the list of courseware. - Publish callback: 1. Receive media stream sharing, changes in media publishing status: -(void)onShareMediaState(String peerId, int state, Map attrs). 2. Total duration, progress, and whether paused of the media stream: -(void)onUpdateAttributeStream(String peerId, long pos, boolean isPlay, HashMap attrMap)

    • Interface Name

    - (void)startShareMedia(String url, boolean isVideo, String toWho, Map<String, Object> attsMap);

    • Parameters
    Parameter Name Required Type Description
    url Yes string File address (listen to notifications: TKRoomManagerObserver, to obtain the file)
    isVideo Yes Boolean Whether it is a video file
    toWho Yes string The object of sharing the media stream, for details, see the relevant definitions in the “Getting Started Guide - Custom Signaling”. It can be a specific user ID, indicating that this signaling is only sent to that user
    attsMap Yes Map Additional parameters, such as file ID, file name, etc
    • Method Example
    1
    2
    3
    4
    5
    6
       String url ="http://";
       long fileid = 123;
       boolean isvideo = true;
       HashMap<String, Object> attrMap = new HashMap<>();
       attrMap.put("fileid", fileid);
       TKRoomManager.getInstance().startShareMedia(url, isvideo, SignalingRole.ALL, attrMap);;
    
    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    stopShareMedia
    • A brief description - Stop publishing media stream file

    Callback:  -(void)onShareMediaState(String peerId, int state, Map attrs)

    • Interface Name

    - (int)stopShareMedia();

    • Parameters
    Parameter Name Required Type Description
    None
    • Method Example

    TKRoomManager.getInstance().stopShareMedia();

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    playMedia
    • A brief description - Play or pause the media stream file shared by the user

    When receiving the callback for the shared media stream: -(void)onShareMediaState(String peerId, int state, Map attrs), call the interface to play the video

    • Interface Name

    - (int)playMedia(boolean isPlay);

    • Parameters
    Parameter Name Required Type Description
    isPlay Yes Boolean true to play, false to pausealse
    • Method Example

    TKRoomManager.getInstance().playMedia(true);

    • Return Value Description
    Type Description
    int 0: Indicates successful invocation; Non-zero: Indicates invocation failure
    seekMedia
    • A brief description - Seek the progress of the shared media stream file

    • Interface Name

    - (int)seekMedia(long pos);

    • Parameters
    Parameter Name Required Type Description
    pos Yes long The seek time progress
    • Method Example

    TKRoomManager.getInstance().seekMedia(20);

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