Play local audio and video files
startPlayAudioFile
- Brief description
Play local audio files
- Interface name
- (int)startPlayAudioFile:(NSString *)filePath loop:(BOOL)loop progress:(progress_block _Nullable)progress;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
filePath | Yes | NSString | File Path |
loop | Yes | BOOL | Whether to play in a loop |
progress | No | progress_block | Callback for playback progress |
- Method Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
- Return Value Description
Type | Description |
---|---|
int | Return the playback audio identifier, the playback ID. If -1 is returned, it indicates playback failure. |
stopPlayAudioFile
- Brief description
Stop playing local audio
- Interface name
- (int)stopPlayAudioFile:(int)audioId;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
audioId | Yes | int | The playback ID returned when startPlayAudioFile succeeds; if this is -1, it indicates stopping all currently playing audio |
- Method Example
[_roomMgr stopPlayAudioFile:1];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
pauseAudioFile
- Brief description
Pause audio playback
- Interface name
- (int)pauseAudioFile:(int)audioId;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
audioId | Yes | int | Playback ID |
- Method Example
[_roomMgr pauseAudioFile:1];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
resumeAudioFile
- Brief description
Resume audio playback
- Interface name
- (int)resumeAudioFile:(int)audioId;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
audioId | Yes | int | Playback ID |
- Method Example
[_roomMgr resumeAudioFile:1];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
setAudioFileVolume
- Brief description
Set the volume for audio playback
- Interface name
- (BOOL)setAudioFileVolume:(CGFloat)volume soundId:(int)audioId;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
volume | Yes | CGFloat | Volume level, range: 0.0 to 1.0, default is 1.0 |
audioId | No | int | Playback ID |
- Method Example
[_roomMgr setAudioFileVolume:0.9 soundId:1];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
startPlayMediaFile
- Brief description
Play local media files
Can play local audio or video files. Returns a playback ID
- Interface name
- (int)startPlayMediaFile:(NSString *)filePath window:(UIView * _Nullable)window loop:(BOOL)loop progress:(progress_block _Nullable)progress;
- (int)startPlayMediaFile:(TKMediaFileParams *)params onStart:(TKLocalMediaState_block _Nullable)startBlock onProgress:(TKLocalMediaProgress_block _Nullable)progressBlock onComplete:(TKLocalMediaState_block _Nullable)completeBlock;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
filePath | Yes | NSString | File path |
window | No | UIView | Video rendering window. If it's only audio, it can be nil. |
loop | Yes | BOOL | Whether to loop playback |
params | Yes | TKMediaFileParams | Playback parameters |
progress/onProgress | No | progress_block/TKLocalMediaProgress_block | Playback progress callback |
onStart | Yes | TKLocalMediaState_block | Playback start callback, including error information if playback fails |
onComplete | No | TKLocalMediaState_block | Playback completion callback |
- Method Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
- Return Value Description
Type | Description |
---|---|
int | Return the playback identifier, i.e., the playback ID. If it returns -1, it indicates that playback has failed. |
stopPlayMediaFile
- Brief description
Stop playing the local media file
- Interface name
- (int)stopPlayMediaFile:(int)playID;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
playID | Yes | int | Playback ID |
- Method Example
[_roomMgr stopPlayMediaFile:2];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
pausePlayMedia
- Brief description
Pause media playback
- Interface name
- (int)pausePlayMedia:(int)playID;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
playID | Yes | int | Playback ID |
- Method Example
[_roomMgr pausePlayMedia:2];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
resumePlayMedia
- Brief description
Resume media playback
- Interface name
- (int)resumePlayMedia:(int)playID;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
playID | Yes | int | Playback ID |
- Method Example
[_roomMgr resumePlayMedia:2];
- Return Value Description
seekPlayMedia
- Brief description
Seek the media playback
- Interface name
- (int)seekPlayMedia:(int)playID pos:(double)pos;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
playID | Yes | int | Playback ID |
pos | Yes | double | Seek to the playback progress position |
- Method Example
[_roomMgr seekPlayMedia:2 pos:0.4];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
setPlayMediaVolume
- Brief description
Set the volume of the media playback
- Interface name
- (int)setPlayMedia:(int)playID volume:(CGFloat)volume;
- Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
playID | Yes | int | Playback ID |
volume | Yes | CGFloat | Volume level, ranging from 0.0 to 1.0, with a default value of 1.0 |
- Method Example
[_roomMgr setPlayMedia:2 volume:0.9];
- Return Value Description
Type | Description |
---|---|
int | 0: Indicates that the call is successful. Non-zero: Indicates that the call has failed. |
Notes
For more return error codes, please refer to the error code descriptions in TKRoomErrorCode