Playback interface
Playback Instructions
The TKRoomSDK supports the complete playback of rooms, which can fully restore the content and process of the real-time live broadcast of the room.
TKPlaybackManager
Playback Main Interface Class
instance
- Brief description
Create a singleton object of TKPlaybackManager, which must be created through this interface.
- Interface Name
+ (instancetype)instance
- Method Example
1 2 3 4 5 6 7 |
|
- Return Value Description
Type | Description |
---|---|
instancetype | TKPlaybackManager |
destory
- Brief description
Destroy the singleton object of TKPlaybackManager, and this interface must be called
- Interface Name
+ (void)destory
- Method Example
[TKPlaybackManager destory];
- Return Value Description
Type | Description |
---|---|
None | None |
setLogLevel
- Brief description
Set the SDK log printing level, and logs will be written to the sandbox.
- Interface Name
+ (int)setLogLevel:(TKLogLevel)level logPath:(NSString * _Nullable)logPath debugToConsole:(BOOL)debug
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
level | Yes | TKLogLevel | Log Level |
llogPath | No | NSString | The path for logs to be written to the sandbox; the default path is: Libary/Caches/TKSDKLogs |
debug | Yes | BOOL | Whether the console outputs logs: YES means logs will be printed to the console, NO means logs will not be printed to the console |
- Method Example
1 2 3 4 5 6 7 8 9 10 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
initWithAppKey
- Brief description
Set the AppID. This interface must be called to initialize room information. 1.To enter the room using the authKey method, the appKey must be passed in. The value of appKey can be found in the corporate backend. 2.To enter the classroom using the token method, the field @"tk_companyDomain" must be passed in the optional parameters
- Interface Name
- (int)initWithAppKey:(NSString *)appKey optional:(NSDictionary * _Nullable)optional
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
appKey | Yes | NSString | Corporate Key |
optional | No | NSDictionary | Room extension information. You can view the relevant setting fields defined in the TKRoomDefines.h file for initialization according to your own needs |
- Method Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
registerRoomManagerDelegate
- Brief description
Register the TKRoomManagerDelegate delegate to receive room information callbacks.
- Interface Name
- (int)registerPlaybackManagerDelegate:(id<TKPlaybackManagerDelegate> _Nullable)playbackDelegate
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
playbackDelegate | No | id | The object that implements the TKPlaybackManagerDelegate delegate |
- 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 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
joinPlaybackRoomWithHost
- Brief description
Playback Room Entry Interface
- Interface Name
1 2 3 4 5 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
host | Yes | NSString | Server address. The default is https |
port | Yes | int | Server port. If TKRoomSettingOptionalSecureSocket is set to YES in the initialization interface [- (int)initWithAppKey:optional:], indicating the use of https or wss, then this port should be set to: 443 (default). If TKRoomSettingOptionalSecureSocket is set to NO or not set in the initialization interface, the port should be: 80 (default). |
nickname | Yes | NSString | Nickname |
roomParams | Yes | NSDictionary | The basic parameters required for the room, of type NSDictionary. For details of the key values, refer to the relevant definitions in TKRoomDefines.h |
userParams | Yes | NSDictionary | The initialization information of the user when entering the room. This information will be saved in the properties attribute of the TKRoomUser object. You can customize it according to your own needs, such as giftNumber (number of gifts) |
- Method Example
AuthKey method:
1 2 3 4 5 6 7 8 9 10 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
leaveRoom
- Brief description
Exit the classroom
After calling the interface, both I and the other users in the room will receive corresponding callbacks. 1.I will receive a callback for myself leaving the room: [- (void)roomManagerRoomLeft][11]. 2.Other users in the room will receive a callback for my departure: - (void)roomManagerUserLeft:(NSString *)peerID.
- Interface Name
- (int)leaveRoom:(BOOL)sync Completion:(completion_block _Nullable)completion;
Synchronized exit
- (int)leaveRoom:(completion_block _Nullable)completion;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
sync | Yes | BOOL | whether executed synchronously |
completion | No | completion_block | The callback of the API call will return an error message if there is an error |
- Method Example
1 2 3 4 5 6 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
getRoomProperty
- Brief description
Get room attributes
This method must be called after the joinRoom API is invoked to obtain valid results. It returns all information related to the room, such as the room ID, room type, and configuration options. Configuration options: These indicate whether the room has enabled teaching assistant features, such as automatic class dismissal, quiz tools, and other interactive teaching functions.
- Interface Name
- (NSDictionary *)getRoomProperty;
- Method Example
NSDictionary *roomProperty = [_playbackMgr getRoomProperty];
- Return Value Description
Type | Description |
---|---|
NSDictionary | Dictionary of room-related information |
getRoomUserWithUId
- Brief description
Retrieve a user based on the user ID
The TKRoomUser is a user object class that stores relevant user information. It must be called after the joinRoom interface is invoked to obtain valid results.
- Interface Name
- (TKRoomUser * _Nullable)getRoomUserWithUId:(NSString *)peerId;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerId | Yes | NSString | User ID |
- Method Example
TKRoomUser *roomUser = [_playbackMgr getRoomUserWithUId:@"ade123456"];
- Return Value Description
Type | Description |
---|---|
TKRoomUser | If there is a user with the specified user ID in the room, it returns the user object of TKRoomUser; otherwise, it returns nil |
playVideo
- Brief description
Play the user's video
This function takes effect after calling initWithAppKey. It can be called multiple times for the same user ID. • Multiple calls: 1.When the same peerID and the same view are passed in, the function does not perform any operation and returns success directly. 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. 3.It must be called on the main thread.
• After calling this interface, there will be relevant callbacks for video playback notifications: 1.Callback for receiving the first frame of data: -(void)roomManagerOnFirstVideoFrameWithPeerID:(NSString )peerID width:(NSInteger)width height:(NSInteger)height mediaType:(TKMediaType)type][5] 2.Callback for video interruption during playback: -(void)roomManagerOnVideoStateChange:(NSString )peerId deviceId:(NSString *)deviceId videoState:(TKRenderState)state mediaType:(TKMediaType)type ][6]
- Interface Name
1 2 3 4 5 6 7 8 9 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerId | Yes | NSString | User ID |
TKRenderMode | Yes | TKRenderMode | The rendering mode is an enumeration. For detailed definitions, see TKRoomDefines.h |
window | Yes | UIView | Video window |
canvas | Yes | TKVideoCanvas | Rendering window class. For detailed definitions, see TKRoomDefines.h |
deviceId | No | NSString | The video's capture device ID, in the case where the user is publishing from multiple cameras simultaneously |
completion | No | completion_block | The callback upon completion of the call 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 is successful. Non-zero: Indicates that the call fails |
playAudio
- Brief description
Play the user's audio
The following requirements must be met: • The function takes effect after calling initWithAppKey. • There is no need to play one's own audio. If the parameter passed to playAudio is one's own ID, the function will directly return. • After calling this interface, the following callback notifications related to audio playback will be triggered: 1.Callback for receiving the first frame of data: -(void)roomManagerOnFirstAudioFrameWithPeerID:(NSString )peerID mediaType:(TKMediaType)type ][7] 2.Callback for audio interruption during video playback: -(void)roomManagerOnAudioStateChange:(NSString )peerId audioState:(TKRenderState)state mediaType:(TKMediaType)type ][8] 3.Callback for changes in audio volume during user audio playback (including one's own volume and remote audio volume): -(void)roomManagerOnAudioVolumeWithPeerID:(NSString *)peerID volume:(int)volume ][9]
- Interface 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
[_playbackMgr playAudio:@"ade123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
unPlayVideo
- Brief description
Stop playing the user's video
The function takes effect after calling initWithAppKey. It must be called on the main thread.
- Interface Name
1 2 3 4 5 |
|
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
peerId | Yes | NSString | User ID |
deviceId | No | NSString | The device ID that captured this video, in the case where the user is publishing from multiple camera devices simultaneously |
completion | No | completion_block | Completion callback |
- Method Example
1 2 |
|
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
unPlayAudio
- Brief description
Stop playing the user's audio
- Interface 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
[_playbackMgr unPlayAudio:@"ade123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
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 | The window for rendering 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 is successful. Non-zero: Indicates that the call fails |
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
[_playbackMgr unPlayMediaFile:@"adc123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
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 paused |
- Method Example
[_playbackMgr pauseMediaFile:NO];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
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 seek time progress |
- Method Example
[_playbackMgr seekMediaFile:1000];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
playScreen
- Brief description
Play screen sharing
The interface specifically used for playing the screen-sharing stream shared by a user. When the callback is received: -(void)roomManagerOnShareScreenState:(NSString *)peerId state:(TKMediaState)state,it indicates that a user has published a screen share, and this interface can be called to play it.
- 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 | The window for rendering 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 is successful. Non-zero: Indicates that the call fails |
unPlayScreen
- Brief description
Stop playing the screen share
The interface specifically used for stopping the playback of the screen-sharing stream shared by a user
- Interface Name
- (int)unPlayScreen:(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
[_playbackMgr unPlayScreen:@"adc123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
playFile
- Brief description
Play the movie file shared by the user
The interface specifically used for playing the movie file stream shared by a user. When the callback is received: -(void)roomManagerOnShareFileState:(NSString )peerId state:(TKMediaState)state extensionMessage:(NSDictionary )message;,it indicates that a user has published a shared movie, and this interface can be called to play it.
- 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 | The window for rendering 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 is successful. Non-zero: Indicates that the call fails |
unPlayFile
- Brief description
Stop playing the movie file shared by the user
The interface specifically used for stopping the playback of the movie file stream shared by a user
- Interface Name
- (int)unPlayFile:(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
[_playbackMgr unPlayFile:@"adc123456" completion:nil];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
seekPlayback
- Brief description
Set the playback progress
- Interface Name
- (int)seekPlayback:(NSTimeInterval)positionTime;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
positionTime | Yes | NSTimeInterval | Progress timestamp |
- Method Example
[_playbackMgr seekPlayback:10000];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
pausePlayback
- Brief description
Pause playback
- Interface Name
- (int)pausePlayback;
- Parameter
None
- Method Example
[_playbackMgr pausePlayback];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
playback
- Brief description
Start playback
- Interface Name
- (int)playback;
- Parameter
None
- Method Example
[_playbackMgr playback];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call fails |
Notes
For more return error codes, please refer to the error code descriptions in TKRoomErrorCode