Share and play media streams.md
startShareMediaFile
- Brief description
Publish a media stream file
The media stream file must have been uploaded to the server. You can listen to the notification: TKWhiteBoardFileListNotification. After entering the room, the SDK will notify all the document lists in the room Publish callback: 1. Received media stream sharing and media publishing status changes -(void)roomManagerOnShareMediaState:(NSString )peerId state:(TKMediaState)state extensionMessage:(NSDictionary )message 2. Media stream total duration, progress, and whether it is paused: -(void)roomManagerUpdateMediaStream:(NSTimeInterval)duration pos:(NSTimeInterval)pos isPlay:(BOOL)isPlay 3. Callback for when the media stream loads the first frame -(void)roomManagerMediaLoaded
- Interface name
1 2 3 4 5 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
mediaPath | Yes | NSString | File path (listen to the notification: TKWhiteBoardFileListNotification to obtain the file) |
isVideo | Yes | BOOL | Whether it is a video file |
toID | Yes | NSString | The object for sharing the media stream, of type NSString. For detailed definitions, refer to TKRoomDefines.h. It can be a specific user ID, indicating that this signaling is sent only to that user |
attributes | Yes | NSDictionary | Additional parameters, such as file ID, file name, etc |
completion | No | completion_block | Completion callback |
- Method Example
1 2 3 4 5 6 7 8 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
stopShareMediaFile
- Brief description
Stop publishing the media stream file
Callback: -(void)roomManagerOnShareMediaState:(NSString )peerId state:(TKMediaState)state extensionMessage:(NSDictionary )message
- Interface name
- (int)stopShareMediaFile:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
completion | No | completion_block | Completion callback |
- Method Example
[_roomMgr stopShareMediaFile:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
playMediaFile
- Brief description
Play the media stream file shared by the user
When receiving the callback for a user sharing a media stream: -(void)roomManagerOnShareMediaState:(NSString )peerId state:(TKMediaState)state extensionMessage:(NSDictionary )message call the interface to play the video
- Interface name
1 2 3 4 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerId | Yes | NSString | User ID |
renderType | Yes | TKRenderMode | Rendering Mode |
window | Yes | UIView | Rendering window for the video |
completion | No | completion_block | Completion callback |
- Method Example
1 2 3 4 5 6 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
unPlayMediaFile
- Brief description
Stop playing the shared media stream file
- Interface name
- (int)unPlayMediaFile:(NSString *)peerId completion:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerId | Yes | NSString | User ID |
completion | No | completion_block | Completion callback |
- Method Example
[_roomMgr unPlayMediaFile:@"adc123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
pauseMediaFile
- Brief description
Pause playing the shared media stream file
- Interface name
- (int)pauseMediaFile:(BOOL)pause;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
pause | Yes | BOOL | Whether to pause |
- Method Example
[_roomMgr pauseMediaFile:NO];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
seekMediaFile
- Brief description
Seek the progress of the shared media stream file
- Interface name
- (int)seekMediaFile:(NSTimeInterval)pos;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
pos | Yes | NSTimeInterval | The time progress for seek |
- Method Example
[_roomMgr seekMediaFile:1000];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
Notes
For more return error codes, please refer to the error code descriptions in TKRoomErrorCode