Publish and play audio and video
publishVideo
- Brief description
Upload local video
The function will take effect after the user successfully enters the room. When the user successfully publishes the video, the following callback function will be received: - (void)roomManagerOnUserVideoStatus:(NSString *)peerID state:(TKMediaState)state.
- API Name
- (int)publishVideo:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
completion | No | completion_block | Callback of the API call |
- Method Example
1 2 3 4 5 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
unPublishVideo
- Brief description
Stop publishing local video
The function will take effect after the user successfully enters the room. When the user successfully stops publishing the video, the following callback function will be received: - (void)roomManagerOnUserVideoStatus:(NSString *)peerID state:(TKMediaState)state.
- API Name
- (int)unPublishVideo:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
completion | No | completion_block | Callback of the API call |
- Method Example
1 2 3 4 5 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
publishAudio
- Brief description
Publish local audio
The function will take effect after the user successfully enters the room. When the user successfully publishes the audio, the following callback function will be received: - (void)roomManagerOnUserAudioStatus:(NSString *)peerID state:(TKMediaState)state.
- API Name
- (int)publishAudio:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
completion | No | completion_block | Callback of the API call |
- Method Example
1 2 3 4 5 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
unPublishAudio
- Brief description
Stop publishing local audio
The function will take effect after the user successfully enters the room. When the user successfully stops publishing the audio, the following callback function will be received: - (void)roomManagerOnUserAudioStatus:(NSString *)peerID state:(TKMediaState)state.
- API Name
- (int)unPublishAudio:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
completion | No | completion_block | Callback of the API call |
- Method Example
1 2 3 4 5 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
playVideo
- Brief description
Play user video. This function will take effect after calling initWithAppKey. This function can be called multiple times for the same user ID.
1.When the same peerID and the same view are passed in, the function will not perform any operation and will directly return success; 2.When the same peerID but a different view is passed in, the video will be rendered on the new view, and the previous view that was playing the video will stop rendering the video; 3.These functions must be called on the main thread.
After calling this interface, there will be relevant callback notifications for playing the video: 1. Callback for receiving the first frame of data: -(void)roomManagerOnFirstVideoFrameWithPeerID:(NSString )peerID width:(NSInteger)width height:(NSInteger)height mediaType:(TKMediaType)type 2. Callback for video interruption during playback: -(void)roomManagerOnVideoStateChange:(NSString )peerId deviceId:(NSString *)deviceId videoState:(TKRenderState)state mediaType:(TKMediaType)type
- API Name
1 2 3 4 5 6 7 8 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerID | Yes | NSString | User ID |
TKRenderMode | Yes | TKRenderMode | The rendering mode enumeration is defined in detail in TKRoomDefines.h |
window | Yes | UIView | Video window |
canvas | Yes | TKVideoCanvas | The rendering window class is defined in detail in TKRoomDefines.h |
deviceId | No | NSString | The capture device ID of this video, which is applicable for the case where the user is publishing from multiple camera devices simultaneously |
completion | No | completion_block | The callback for completion of the call, which can handle operations after playback is finished |
- 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 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
playAudio
- Brief description
Play user audio The playback of user audio will take effect only after calling initWithAppKey. There is no need to play your own audio. If the playAudio function is passed your own ID as a parameter, the function will directly return.
After calling this interface, there will be callback notifications related to audio playback: 1. Callback for receiving the first frame of data: -(void)roomManagerOnFirstAudioFrameWithPeerID:(NSString )peerID mediaType:(TKMediaType)type 2. Callback for audio interruption during video playback: -(void)roomManagerOnAudioStateChange:(NSString )peerId audioState:(TKRenderState)state mediaType:(TKMediaType)type 3. Callback for changes in audio volume when playing user audio (including both local and remote audio volumes): -(void)roomManagerOnAudioVolumeWithPeerID:(NSString *)peerID volume:(int)volume
- API Name
- (int)playAudio:(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 playAudio:@"ade123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
unPlayVideo
- Brief description
Stop playing user's video
The call will take effect only after invoking initWithAppKey. All calls must be made on the main thread.
- API Name
1 2 3 4 5 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerID | Yes | NSString | User ID |
deviceId | No | NSString | The device ID of the camera capturing this video. This is applicable in cases where the user is publishing from multiple cameras simultaneously |
completion | No | completion_block | Completion callback |
- Method Example
1 2 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call was successful. Non-zero: Indicates that the call failed |
unPlayAudio
- Brief description
Stop playing user's audio
- API Name
- (int)unPlayAudio:(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 unPlayAudio:@"ade123456" completion:nil];
- 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