TUIAudioEffectManager
is a singleton object that manages background music, sound effects and vocal effects.// npmnpm i @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3 --save// pnpmpnpm i @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3 --save// yarnyarn add @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3
import TUIRoomEngine, {TUIAudioEffectManager, TUIVoiceReverbType, TUIVoiceChangerType} from '@tencentcloud/tuiroom-engine-electron';const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();audioEffectManager.setVoiceReverbType(TUIVoiceReverbType.kVoiceReverbType_3);audioEffectManager.setVoiceChangerType(TUIVoiceChangerType.kVoiceChangerType_1);audioEffectManager.setMusicObserver({onStart: (id: number, errCode: number)=>{console.log(`music start play:`, id, errCode);},onPlayProgress: (id: number, curPtsMS: number, durationMS: number) => {console.log(`music play progress:`, id, curPtsMS, durationMS);},onComplete: (id: number, errCode: number) => {console.log(`music complete:`, id, errCode);},});audioEffectManager.startPlayMusic({id: 1,path: 'https://web.sdk.qcloud.com/trtc/electron/download/resources/media/bgm/PositiveHappyAdvertising.mp3',publish: true,loopCount: 2,isShortFile: false,startTimeMS: 0,endTimeMS: 0,});
Method | Description |
Set the reverb effect for vocals | |
Set the voice changer effect for vocals | |
Set the event callback for background music | |
Start playing background music | |
Stop playing background music | |
Pause playing background music | |
Resume playing background music | |
Set the local and remote volume levels for all background music | |
Set the remote volume level for a specific background music | |
Set the local volume level for a specific background music | |
Get the current playback position of the background music (in milliseconds) | |
Get the total duration of the background music (in milliseconds) | |
Set the playback position of the background music (in milliseconds) |
Type | Description |
Background music playback control information | |
Background music playback event listener |
Enum | Description |
Voice reverb effect type | |
Voice changer effect type |
import TUIRoomEngine, {TUIAudioEffectManager, TUIVoiceReverbType} from '@tencentcloud/tuiroom-engine-electron';const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();audioEffectManager.setVoiceReverbType(TUIVoiceReverbType.kVoiceReverbType_3);
Parameter | Type | Validation | Default value | Description |
type | - | - | Voice reverb effect type |
void
import TUIRoomEngine, {TUIAudioEffectManager, TUIVoiceChangerType} from '@tencentcloud/tuiroom-engine-electron';const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();audioEffectManager.setVoiceChangerType(TUIVoiceChangerType.kVoiceChangerType_1);
Parameter | Type | Validation | Default value | Description |
type | - | - | Voice changer effect type |
void
import TUIRoomEngine, {TUIAudioEffectManager} from '@tencentcloud/tuiroom-engine-electron';const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();audioEffectManager.setMusicObserver({onStart: (id: number, errCode: number)=>{console.log(`music start play:`, id, errCode);},onPlayProgress: (id: number, curPtsMS: number, durationMS: number) => {console.log(`music play progress:`, id, curPtsMS, durationMS);},onComplete: (id: number, errCode: number) => {console.log(`music complete:`, id, errCode);},});
Parameter | Type | Validation | Default value | Description |
observer | - | - | Background music playback event listener |
void
import TUIRoomEngine, {TUIAudioEffectManager} from '@tencentcloud/tuiroom-engine-electron';const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();audioEffectManager.startPlayMusic({id: 1,path: 'https://web.sdk.qcloud.com/trtc/electron/download/resources/media/bgm/PositiveHappyAdvertising.mp3',publish: true,loopCount: 2,isShortFile: false,startTimeMS: 0,endTimeMS: 0,});
Parameter | Type | Validation | Default value | Description |
param | - | - | Background Music Parameters |
void
Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
void
Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
void
Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
void
Parameter | Type | Validation | Default value | Description |
volume | number | 0-100 | 60 | Music volume. Range:[0, 100]. Default value: 60. |
void
Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
volume | number | 0-100 | 60 | Music volume. Range:[0, 100]. Default value: 60. |
void
Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
volume | number | 0-100 | 60 | Music volume. Range:[0, 100]. Default value: 60. |
void
Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
Promise
<number
> Current playing position in millisecnds. If it fails, return -1.Parameter | Type | Validation | Default value | Description |
path | string | - | - | Music File Path |
Promise
<number
> Total duration in milliseconds. If it fails, return -1.Parameter | Type | Validation | Default value | Description |
id | number | - | - | Background music ID |
pts | number | - | - | Playing position in milliseconds |
void
Field | Type | Description |
id | number | Music ID. Multiple music tracks are allowed to be played, so an ID is needed to mark them for controlling the start, stop, volume, etc. of the music. |
path | string | The full path or URL address of the audio file. Supported audio formats include MP3, AAC, M4A, WAV. |
loopCount | number | Number of times the music is looped. The range is 0 - any positive integer, default value: 0. 0 means playing the music once; 1 means playing the music twice; and so on. |
publish | boolean | Whether to transmit the music to the remote end. true: The music can be heard by remote users while playing locally; false: The anchor can only hear the music locally, and remote audiences cannot hear it. Default value: false. |
isShortFile | boolean | Whether it is a short music file. true: A short music file that needs to be repeated; false: A normal music file. Default value: false. |
startTimeMS | number | Music start playback time point, unit: milliseconds. |
endTimeMS | number | Music end playback time point, unit milliseconds, 0 means play to the end of the file. |
Field | Type | Description |
onStart | Function | null | Background music start playback event |
onPlayProgress | Function | null | Background music playback progress event |
onComplete | Function | null | Background music playback completion event |
Parameter | Type | Description |
id | number | Background music ID |
errCode | number | Error code. 0: Playback started successfully; -4001: Failed to open file, such as unsupported audio file format, local audio file does not exist, network audio file cannot be accessed, etc. |
Parameter | Type | Description |
id | number | Background music ID |
curPtsMS | number | Current playback timestamp of the background music |
durationMS | number | Duration of the background music |
Parameter | Type | Description |
id | number | Background music ID |
errCode | number | Error code. 0: Playback ended; -4002: Decoding failed, such as corrupted audio file, network audio file server cannot be accessed, etc. |
Enumeration item | Type | Description |
kVoiceReverbType_0 | number | Off |
kVoiceReverbType_1 | number | KTV |
kVoiceReverbType_2 | number | Small room |
kVoiceReverbType_3 | number | Auditorium |
kVoiceReverbType_4 | number | Deep |
kVoiceReverbType_5 | number | Loud |
kVoiceReverbType_6 | number | Metallic |
kVoiceReverbType_7 | number | Magnetic |
kVoiceReverbType_8 | number | Ethereal |
kVoiceReverbType_9 | number | Studio |
kVoiceReverbType_10 | number | Mellow |
kVoiceReverbType_11 | number | Studio 2 |
Enumeration item | Type | Description |
kVoiceChangerType_0 | number | Off |
kVoiceChangerType_1 | number | Naughty child |
kVoiceChangerType_2 | number | Lolita |
kVoiceChangerType_3 | number | Uncle |
kVoiceChangerType_4 | number | Heavy metal |
kVoiceChangerType_5 | number | Cold |
kVoiceChangerType_6 | number | Foreign accent |
kVoiceChangerType_7 | number | Trapped beast |
kVoiceChangerType_8 | number | Otaku |
kVoiceChangerType_9 | number | Strong current |
kVoiceChangerType_10 | number | Heavy machinery |
kVoiceChangerType_11 | number | Ethereal |
Was this page helpful?