tencent_rtc_sdk. Obtain the instance via TRTCCloud's getAudioEffectManager() and then call the APIs.API | Description |
Enables in-ear monitoring. | |
Sets the in-ear monitoring volume. | |
Sets the reverb effect of the voice. | |
Sets the voice changing effect. | |
Sets the voice volume. | |
Sets the voice pitch. |
API | Description |
Sets the background music event callback. | |
Starts playing background music. | |
Stops playing background music. | |
Pauses playing background music. | |
Resumes playing background music. |
API | Description |
Sets the local and remote volume of all background music. | |
Sets the remote volume of a specific background music. | |
Sets the local volume of a specific background music. | |
Adjusts the pitch of background music. | |
Adjusts the playback speed of background music. | |
Adjusts the speed of scratching. |
API | Description |
Gets the playback progress of background music (in milliseconds). | |
Gets the total duration of background music (in milliseconds). | |
Sets the playback progress of background music (in milliseconds). | |
Gets the number of audio tracks of background music. | |
Specifies the audio track for background music playback. |
API | Description |
Sets the preloading event callback. | |
Preloads background music. |
void enableVoiceEarMonitor(bool enable)
Parameter | Type | Description |
enable | bool | true: Enable.false: Disable. |
void setVoiceEarMonitorVolume(int volume)
Parameter | Type | Description |
volume | int | Volume. Value range: 0 - 100. Default value: 100. |
volume to 100, you can set volume to up to 150, but this may have side effects.void setVoiceReverbType(TXVoiceReverbType type)
Parameter | Type | Description |
type |
void setVoiceChangerType(TXVoiceChangerType type)
Parameter | Type | Description |
type |
void setVoiceCaptureVolume(int volume)
Parameter | Type | Description |
volume | int | Volume. Value range: 0 - 100. Default value: 100. |
volume to 100, you can set volume to up to 150, but this may have side effects.void setVoicePitch(double pitch)
Parameter | Type | Description |
pitch | double | Pitch. Value range: -1.0 - 1.0. Default value: 0.0. |
void setMusicObserver(int musicId, TXMusicPlayObserver? observer)
Parameter | Type | Description |
musicId | int | Music ID. |
observer | TXMusicPlayObserver? |
observer to null to completely release the callback.void startPlayMusic(AudioMusicParam musicParam)
Parameter | Type | Description |
musicParam |
const int musicId = 1;audioEffectManager.setMusicObserver(musicId, TXMusicPlayObserver(onStart: (int id, int errorCode) {debugPrint('music $id start, errorCode: $errorCode');},onPlayProgress: (int id, int curPtsMS, int durationMS) {debugPrint('music $id progress: $curPtsMS / $durationMS');},onComplete: (int id, int errorCode) {debugPrint('music $id complete, errorCode: $errorCode');},));audioEffectManager.startPlayMusic(AudioMusicParam(id: musicId,path: '/path/to/music.mp3',publish: true,));
void stopPlayMusic(int id)
Parameter | Type | Description |
id | int | Music ID. |
void pausePlayMusic(int id)
Parameter | Type | Description |
id | int | Music ID. |
void resumePlayMusic(int id)
Parameter | Type | Description |
id | int | Music ID. |
void setAllMusicVolume(int volume)
Parameter | Type | Description |
volume | int | Volume. Value range: 0 - 100. Default value: 60. |
volume to 100, you can set volume to up to 150, but this may have side effects.void setMusicPublishVolume(int id, int volume)
Parameter | Type | Description |
id | int | Music ID. |
volume | int | Volume. Value range: 0 - 100. Default value: 60. |
volume to 100, you can set volume to up to 150, but this may have side effects.void setMusicPlayoutVolume(int id, int volume)
Parameter | Type | Description |
id | int | Music ID. |
volume | int | Volume. Value range: 0 - 100. Default value: 60. |
volume to 100, you can set volume to up to 150, but this may have side effects.void setMusicPitch(int id, double pitch)
Parameter | Type | Description |
id | int | Music ID. |
pitch | double | Pitch. Value range: a floating-point number in [-1, 1]. Default value: 0.0. |
void setMusicSpeedRate(int id, double rate)
Parameter | Type | Description |
id | int | Music ID. |
rate | double | Speed. Value range: a floating-point number in [0.5, 2]. Default value: 1.0. |
void setMusicScratchSpeedRate(int id, double scratchSpeedRate)
Parameter | Type | Description |
id | int | Music ID. |
scratchSpeedRate | double | Scratching speed. Value range: a floating-point number in [-12.0, 12.0]. Default value: 1.0. Positive and negative values indicate direction (forward/reverse), and the absolute value indicates the speed. |
int getMusicCurrentPosInMS(int id)
Parameter | Type | Description |
id | int | Music ID. |
-1 on failure.int getMusicDurationInMS(String path)
Parameter | Type | Description |
path | String | Music file path. |
-1 on failure.void seekMusicToPosInTime(int id, int pts)
Parameter | Type | Description |
id | int | Music ID. |
pts | int | Playback progress, in milliseconds. |
int getMusicTrackCount(int id)
Parameter | Type | Description |
id | int | Music ID. |
void setMusicTrack(int id, int trackIndex)
Parameter | Type | Description |
id | int | Music ID. |
trackIndex | int | Specifies which audio track to play (the first track is played by default). Value range: [0, total number of tracks). |
void setPreloadObserver(TXMusicPreloadObserver? observer)
Parameter | Type | Description |
observer | TXMusicPreloadObserver? | Preloading event callback. For details, see TXMusicPreloadObserver. Pass null to remove the callback. |
void preloadMusic(AudioMusicParam musicParam)
Parameter | Type | Description |
musicParam |
stopPlayMusic; otherwise, the memory will not be released.stopPlayMusic first.musicParam passed to startPlayMusic is exactly the same as that used for preloading.Enum Value | Value | Description |
type0 | 0 | Disable the effect. |
type1 | 1 | KTV. |
type2 | 2 | Small room. |
type3 | 3 | Great hall. |
type4 | 4 | Deep. |
type5 | 5 | Resonant. |
type6 | 6 | Metallic. |
type7 | 7 | Magnetic. |
type8 | 8 | Ethereal. |
type9 | 9 | Studio. |
type10 | 10 | Melodious. |
type11 | 11 | Studio 2. |
Enum Value | Value | Description |
type0 | 0 | Disable the effect. |
type1 | 1 | Naughty kid. |
type2 | 2 | Little girl. |
type3 | 3 | Middle-aged man. |
type4 | 4 | Heavy metal. |
type5 | 5 | Cold. |
type6 | 6 | Foreigner. |
type7 | 7 | Trapped beast. |
type8 | 8 | Otaku. |
type9 | 9 | Strong current. |
type10 | 10 | Heavy machinery. |
type11 | 11 | Ethereal. |
Field | Type | Default Value | Description |
id | int | Required | Music ID. The SDK allows playing multiple pieces of music, so an ID is needed to mark each one and control its start, stop, volume, etc. |
path | String | Required | Absolute path or URL of the music file. The mp3, aac, m4a and wav formats are supported. |
loopCount | int | 0 | Number of times the music loops. Value range: 0 or any positive integer. 0 means playing the music once.1 means playing the music twice, and so on. |
publish | bool | false | Whether to send the music to remote users. true: While the music is played locally, remote users can also hear it.false: Only the anchor can hear the music locally; remote audience members cannot hear it. |
isShortFile | bool | false | Whether the file played is a short music file. true: A short music file that needs to be played repeatedly.false: A normal music file. |
startTimeMS | int | 0 | Time point at which the music starts playing, in milliseconds. |
endTimeMS | int | 0 | Time point at which the music stops playing, in milliseconds. 0 means playing to the end of the file. |
final void Function(int id, int errorCode) onStart
Parameter | Type | Description |
id | int | Music ID. |
errorCode | int | 0: Playback started successfully.-4001: Failed to open the file, for example, invalid data found when processing input, or ffmpeg protocol not found.-4005: Invalid path. Check whether the path passed in points to a valid music file.-4006: Invalid URL. Use a browser to check whether the expected music file can be downloaded from the URL passed in.-4007: No audio stream. Check whether the file passed in is a valid audio file and whether it is corrupted.-4008: Unsupported format. Check whether the format of the file passed in is supported. Mobile supports mp3, aac, m4a, wav, ogg, mp4 and mkv; desktop supports mp3, aac, m4a, wav, mp4 and mkv. |
final void Function(int id, int curPtsMSm, int durationMS) onPlayProgress
Parameter | Type | Description |
id | int | Music ID. |
curPtsMSm | int | Current playback time point, in milliseconds. |
durationMS | int | Total duration of the music, in milliseconds. |
final void Function(int id, int errorCode) onComplete
Parameter | Type | Description |
id | int | Music ID. |
errorCode | int | 0: Playback ended.-4002: Decoding failed, for example, the audio file is corrupted or the online audio file server is inaccessible. |
final void Function(int id, int progress) onLoadProgress
Parameter | Type | Description |
id | int | Music ID. |
progress | int | Preloading progress. |
final void Function(int id, int errorCode) onLoadError
Parameter | Type | Description |
id | int | Music ID. |
errorCode | int | -4001: Failed to open the file, for example, invalid data found when processing input, or ffmpeg protocol not found.-4002: Decoding failed, for example, the audio file is corrupted or the online audio file server is inaccessible.-4003: The number of preloads exceeds the limit. Call stopPlayMusic first to release unused preloads.-4005: Invalid path. Check whether the path passed in points to a valid music file.-4006: Invalid URL. Use a browser to check whether the expected music file can be downloaded from the URL passed in.-4007: No audio stream. Check whether the file passed in is a valid audio file and whether it is corrupted.-4008: Unsupported format. Check whether the format of the file passed in is supported. Mobile supports mp3, aac, m4a, wav, ogg, mp4 and mkv; desktop supports mp3, aac, m4a, wav, mp4 and mkv. |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan