# Audio player

**Detailed Description**

This section contains audio player APIs.

- *group* Telematics\_audio\_player

    - Enums

- enum RepeatType

    - Defines whether to play or skip this file.

*Values:*

- enumerator COUNT

    - Play the file for given number of times

- enumerator INDEFINITELY

    - Play the file indefinitely

- enumerator SKIP

    - Do not play the file

- struct RepeatInfo

    - Defines number of times a file should be played.

Public Members

- RepeatType type

    - Please refer RepeatType for details

- uint32\_t count

    - When using RepeatType::COUNT, defines number of times a file should be played

- struct PlaybackConfig

    - Specifies files to play and how to play.

Public Members

- std::string absoluteFilePath

    - Absolute path of the audio file. Supports playback of audio files with the following standard header lengths:

1. AudioFormat::PCM\_16BIT\_SIGNED: 44 bytes (RIFF)
2. AudioFormat::AMRWB\_PLUS: 2 bytes (ETSI TS 126 290 V8.0.0 (2009-01) section 8.3)
3. AudioFormat::AMRWB: 9 bytes (RFC4867)
4. AudioFormat::AMRNB: 6 bytes (RFC4867)

- RepeatInfo repeatInfo

    - Defines how a file should be played

- StreamConfig streamConfig

    - Defines how an audio stream should be configured to play this file

- class IPlayListListener

    - Receives status of the playback.

Public Functions

- inline virtual void onPlaybackStarted()

    - Invoked when playback is started as a response to explicitly calling IAudioPlayer::startPlayback().

- inline virtual void onPlaybackStopped()

    - Invoked whenever playback is stopped as a response to explicitly calling IAudioPlayer::stopPlayback() or when playback is stopped due to an error for example audio can not be played or volume/mute can not be set.

This API will not be invoked if all the files in the playback list are successfully played to completion. In such a scenario, onPlaybackFinished will be invoked on completion.

- inline virtual void onError(telux::common::ErrorCode error, std::string file)

    - Invoked whenever an error occurs.

- Parameters:

    - - **error** – **[in]** Appropriate error code telux::common::ErrorCode
- **file** – **[in]** File which was getting played when this error occurred. It can be empty if an error occurred before opening any file.

- inline virtual void onFilePlayed(std::string file)

    - Invoked whenever each file has been played from the playlist. If a file is played repeatedly, it will be called that many times. If a file is played indefinitely, it is called every time file is played completely. If an error occurs or playback is stopped, this callback is not called.

- Parameters:

    - **file** – **[in]** File played successfully

- inline virtual void onPlaybackFinished()

    - Invoked to confirm all files have been played gracefully as specified by IAudioPlayer::startPlayback().

- inline virtual ~IPlayListListener()

    - Destructor of IPlayListListener.

- class IAudioPlayer

    - IAudioPlayer manages playback of a playlist of audio files. The playlist could contain one or more files. Clients can also specify how many times the file should be played, in case repetition is required.

Public Functions

- virtual telux::common::ErrorCode startPlayback(std::vector&lt;PlaybackConfig&gt; &playbackConfigs, std::weak\_ptr&lt;IPlayListListener&gt; statusListener) = 0

    - Plays audio files in the manner as specified by the `playbackConfigs`. Files can have same or different audio format. Multiple files can be specified in one call to this method.

On platforms with access control enabled, the caller must have TELUX\_AUDIO\_PLAY, permission to invoke this method successfully.

Note

Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.

- Parameters:

    - - **playbackConfigs** – **[in]** List of files to play and the manner in which to play
- **statusListener** – **[in]** Receives various status updates in IPlayListListener

- Returns:

    - telux::common::ErrorCode::SUCCESS, if the playback is started, telux::common::ErrorCode::ACCESS\_DENIED, if the caller doesn’t have permission to call this API, telux::common::ErrorCode::INVALID\_STATE, if a playback is already in progress, telux::common::ErrorCode::INVALID\_ARGUMENTS, if no files are given, an appropriate error code in all other cases.

- virtual telux::common::ErrorCode stopPlayback() = 0

    - Stops the playback started with startPlayback().

If the file is configured with RepeatType::COUNT, there is no need to call this method as playback will stop automatically after file has been played successfully. However, client can call this method anytime to stop playback explicitly.

If the file is configured with RepeatType::INDEFINITELY, calling this method is the only way to stop playback.

On platforms with access control enabled, the caller must have TELUX\_AUDIO\_PLAY, permission to invoke this method successfully.

Note

Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.

- Returns:

    - telux::common::ErrorCode::SUCCESS, if the playback is stopped, telux::common::ErrorCode::INVALID\_STATE, if there is no playback in-progress, telux::common::ErrorCode::ACCESS\_DENIED, if the caller doesn’t have permission to call this API, an appropriate error code in all other cases.

- virtual telux::common::ErrorCode setVolume(float volumeLevel) = 0

    - Sets the volume level of the audio stream.

- Parameters:

    - **volumeLevel** – **[in]** Specifies the volume level (0.0 to 1.0) to set

- Returns:

    - telux::common::ErrorCode::SUCCESS if the given volume is set, otherwise, an appropriate error code.

- virtual telux::common::ErrorCode getVolume(float &volumeLevel) = 0

    - Retrieves the current volume level of the audio stream.

- Parameters:

    - **volumeLevel, Current** – **[out]** volume level (0.0 to 1.0)

- Returns:

    - telux::common::ErrorCode::SUCCESS if the volume is retrieved, otherwise, an appropriate error code.

- virtual telux::common::ErrorCode setMute(bool enable) = 0

    - Mutes or unmutes the audio.

- Parameters:

    - **enable** – **[in]** True to mute the audio, false to unmute the audio

- Returns:

    - telux::common::ErrorCode::SUCCESS if the playback is muted/unmuted as specified otherwise, an appropriate error code.

- virtual telux::common::ErrorCode getMute(bool &enable) = 0

    - Retrieves the current mute state of the audio stream.

- Parameters:

    - **enable** – **[out]** True if the audio is muted currently otherwise false

- Returns:

    - telux::common::ErrorCode::SUCCESS if the mute state is retrieved, otherwise, an appropriate error code.

- virtual telux::common::ErrorCode setDevice(std::vector&lt;DeviceType&gt; devices) = 0

    - Associates the given audio devices with the audio stream.

- Parameters:

    - **devices** – **[in]** List of the audio devices

- Returns:

    - telux::common::ErrorCode::SUCCESS if the device is set, otherwise, an appropriate error code.

- virtual telux::common::ErrorCode getDevice(std::vector&lt;DeviceType&gt; &devices) = 0

    - Retrieves list of the audio devices associated with the audio stream.

- Parameters:

    - **devices** – **[out]** List of the audio devices

- Returns:

    - telux::common::ErrorCode::SUCCESS if the list is retrieved, otherwise, an appropriate error code.

- inline virtual ~IAudioPlayer()

    - Destructor of the IAudioPlayer.

Last Published: May 20, 2026

Previous Topic
 
telux::audio::ITranscoder Next Topic

AudioFactory