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 |
|
- 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 |