@detail api
@brief Gets the track count of the current media file.
@return + >= 0:Success. Return the track count of the current media file.
- < 0:Failed.
@note
- Call this API only when audio is mixing.
- This API is valid for audio file, not PCM data.
@detail api
@brief Gets the actual playback duration of the mixed media file, in milliseconds.
@return
- >0: Success, the actual playback time.
- < 0: Failed.
@note
- The actual playback time refers to the playback time of the song without being affected by stop, jump, double speed, and freeze. For example, if the song stops playing for 30 seconds at 1:30 or skips to 2:00, and then continues to play normally for 2 minutes, the actual playing time is 3 minutes and 30 seconds.
- Call this API only when audio is mixing and the interval set by setProgressInterval:{@link #ByteRTCMediaPlayer#setProgressInterval} is above 0.
- The API is valid for audio file, not PCM data.
@detail api
@brief Gets the playback progress of the media file.
@return
- >0: Success, the playback progress of media file in ms.
- < 0: Failed.
@note
- Call this API only when audio is mixing.
- The API is valid for audio file, not PCM data.
@detail api
@brief Get the state of the media player.
@return The current state of the media player. See ByteRTCPlayerState{@link #ByteRTCPlayerState}.
@note You can call this method after the creating a ByteRTCMediaPlayer instance.
@detail api
@brief Gets the duration of the media file.
@return
- >0: Success, the duration of the media file in milliseconds.
- < 0: Failed.
@note
- Call this API only when audio is mixing.
- The API is valid for audio file, not PCM data.
@detail api
@brief Gets the current volume.
@param type See ByteRTCAudioMixingType{@link #ByteRTCAudioMixingType}.
@return
- >0: Success, the current volume.
- < 0: Failed.
@note Call this API only when audio is mixing, including media file mixing and PCM mixing.
@detail api
@brief Open the audio file.
You can only open one audio file with one player instance at the same time. For multiple audio files at the same time, create multiple player instances.
For audio file in PCM format, see openWithCustomSource:config:{@link #ByteRTCMediaPlayer#openWithCustomSource:config}. openWithCustomSource and this API are mutually exclusive.
@param filePath Audio file paths.
URL of online file, URI of local file, or full path to local file are supported. For URL of online file, only the https protocol is supported.
Recommended sample rate for audio effect files: 8KHz、16KHz、22.05KHz、44.1KHz、48KHz.
Local audio effect file formats supported by different platforms:
@detail api
@brief Enable audio mixing with audio raw data.
To open the audio file, see open:config:{@link #ByteRTCMediaPlayer#open:config}. open and this API are mutually exclusive.
@param source See ByteRTCMediaPlayerCustomSource{@link #ByteRTCMediaPlayerCustomSource}.
@param config See ByteRTCMediaPlayerConfig{@link #ByteRTCMediaPlayerConfig}.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- After calling this API, you must call pushExternalAudioFrame:{@link #ByteRTCEngine#pushExternalAudioFrame} to push audio data and start the audio mixing.
- To stop the raw data audio mixing, call stop{@link #ByteRTCMediaPlayer#stop}.
@detail api
@brief After calling open:config:{@link #ByteRTCMediaPlayer#open:config}, or start{@link #ByteRTCMediaPlayer#start} to start audio mixing, call this API to pause audio mixing.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
@detail api
@brief Push PCM audio frame data for mixing.
@param audioFrame See ByteRTCAudioFrame{@link #ByteRTCAudioFrame}.
- The audio sampling format must be S16. The data format within the audio buffer must be PCM, and its capacity should be audioFrame.samples × audioFrame.channel × 2.
- A specific sample rate and the number of channels must be specified; it is not supported to set them to automatic.
@return
- 0: Success.
- < 0: Failed.
@note
- Before calling this method, the raw audio data mixing must be enabled through openWithCustomSource:config:{@link #ByteRTCMediaPlayer#openWithCustomSource:config}.
- Suggestions: Before pushing data for the first time, please cache a certain amount of data (like 200 ms) on the application side, and then push it at once. Schedule subsequent push operation every 10 ms with audio data of 10 ms.
- To pause the playback, just pause the push.
@detail api
@brief Register an observer to receive related callbacks when the local media file is mixing.
@param observer See ByteRTCMediaPlayerAudioFrameObserver{@link #ByteRTCMediaPlayerAudioFrameObserver}.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
The API is valid for audio file, not PCM data.
@detail api
@brief After calling pause{@link #ByteRTCMediaPlayer#pause} to pause audio mixing, call this API to resume audio mixing.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
The API is valid for audio file, not PCM data.
@detail api
@brief Specifies the playback track of the current media file.
@param index The specified playback audio track, starting from 0, and the range is [0, getAudioTrackCount()-1]. The value must be less than the return value of getAudioTrackCount{@link #ByteRTCMediaPlayer#getAudioTrackCount}.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- Call this API only when audio is mixing.
- This API is valid for audio file, not PCM data.
@detail api
@brief Sets the channel mode of the mixing of the media file.
@param mode The mode of channel. The default channel mode is the same as the source file. See ByteRTCAudioMixingDualMonoMode{@link #ByteRTCAudioMixingDualMonoMode}.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- Call this API only when audio is mixing.
- Audio file is supported, but not PCM data.
@detail api
@brief Set the pitch of the local audio file mixing. Usually used in karaoke scenes.
@param pitch The increase or decrease value compared with the original pitch of the music file. The range is [-12, 12]. The default value is 0. The pitch distance between two adjacent values is half a step. A positive value indicates a rising pitch, and a negative value indicates a falling pitch.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- Call this API only when audio is mixing.
- Support audio file only and not PCM data.
@detail api
@brief Set the event handler.
@param handler See ByteRTCMediaPlayerEventHandler{@link #ByteRTCMediaPlayerEventHandler}.
@return
- 0: Success.
- < 0: Failed.
@detail api
@brief To call enableVocalInstrumentBalance:{@link #ByteRTCEngine#enableVocalInstrumentBalance} to adjust the volume of the mixed media file or the PCM audio data, you must pass in its original loudness through this API.
@param loudness Original loudness in lufs. The range is [-70.0, 0.0].
When the value is less than -70.0lufs, it will be adjusted to -70.0lufs by default, and if it is more than 0.0lufs, the loudness will not be equalized. The default value is 1.0lufs, which means no processing.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- Call this API only when audio is mixing.
- The API is valid for audio file and PCM data.
@detail api
@brief Set the playback speed of the audio file.
@param speed The ratio of the actual playback speed than that of the original speed of the audio file in %. The range is [50,200]. The default value is 100.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- Call this API only when audio is mixing.
- The API is valid for audio file and not PCM data.
@detail api
@brief Sets the starting playback position of the media file.
@param position The starting position of the media file in milliseconds.
You can get the total duration of the media file through getTotalDuration{@link #ByteRTCMediaPlayer#getTotalDuration}. The value of position should be less than the total duration of the media file.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- The API is valid for audio file, not PCM data.
- When playing online files, calling this API may cause playback delay.
@detail api
@brief Set the interval of the periodic callback onMediaPlayerPlayingProgress:progress:{@link #ByteRTCMediaPlayerEventHandler#onMediaPlayerPlayingProgress:progress} during audio mixing.
@param interval interval in ms.
- interval > 0: The callback is enabled. The actual interval is a multiple of 10. If the input value is not divisible by 10, it will be automatically rounded up. For example, if the input is 52, the actual interval will be 60 milliseconds.
- interval <= 0: The callback is disabled.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
- Call this API only when audio is mixing.
- This API is valid for audio file, not PCM data.
@detail api
@brief Adjusts the volume of the specified audio mixing, including media file mixing and PCM mixing.
@param volume The ratio of the volume to the original volume in % with overflow protection. The range is [0, 400] and the recommended range is [0, 100].
@param type See ByteRTCAudioMixingType{@link #ByteRTCAudioMixingType}.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note Call this API only when audio is mixing.
@detail api
@brief Start playing the audio. Call this API when you call open:config:{@link #ByteRTCMediaPlayer#open:config} and set AutoPlay=False.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.
@note
@detail api
@brief After calling open:config:{@link #ByteRTCMediaPlayer#open:config}, start{@link #ByteRTCMediaPlayer#start}, or openWithCustomSource:config:{@link #ByteRTCMediaPlayer#openWithCustomSource:config} to start audio mixing, call this method to stop audio mixing.
@return
- 0: Success.
- < 0 : Fail. See ByteRTCReturnStatus{@link #ByteRTCReturnStatus} for more details.