Telematics SDK - API Reference  v1.64.0
Audio player

Data Structures

struct  telux::audio::RepeatInfo
 
struct  telux::audio::PlaybackFile
 
class  telux::audio::IPlayListListener
 
class  telux::audio::IAudioPlayer
 

Enumerations

enum  telux::audio::RepeatType { telux::audio::RepeatType::COUNT, telux::audio::RepeatType::INDEFINITELY, telux::audio::RepeatType::SKIP }
 

Detailed Description

This section contains audio player APIs.


Data Structure Documentation

struct telux::audio::RepeatInfo

Defines number of times a file should be played.

Data Fields
RepeatType type

Please refer RepeatType for details

uint32_t count

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

struct telux::audio::PlaybackFile

Specifies files to play and how to play.

Data Fields
string absoluteFilePath

Absolute path of the file

RepeatInfo repeatInfo

Defines how a file should be played

class telux::audio::IPlayListListener

Receives status of the playback.

Public Member Functions

virtual void onPlaybackStarted ()
 
virtual void onPlaybackStopped ()
 
virtual void onError (telux::common::ErrorCode error, std::string file)
 
virtual void onFilePlayed (std::string file)
 
virtual void onPlaybackFinished ()
 
virtual ~IPlayListListener ()
 

Constructor & Destructor Documentation

virtual telux::audio::IPlayListListener::~IPlayListListener ( )
virtual

Destructor of IPlayListListener.

Member Function Documentation

virtual void telux::audio::IPlayListListener::onPlaybackStarted ( )
virtual

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

virtual void telux::audio::IPlayListListener::onPlaybackStopped ( )
virtual

Invoked whenever playback is stopped as a response to explicitly calling IAudioPlayer::stopPlayback() or when playback is stopped due to an error.

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.

virtual void telux::audio::IPlayListListener::onError ( telux::common::ErrorCode  error,
std::string  file 
)
virtual

Invoked whenever an error occurs.

Parameters
[in]errorAppropriate error code telux::common::ErrorCode
[in]fileFile which was getting played when this error occurred. It can be empty if error occurred before opening any file.
virtual void telux::audio::IPlayListListener::onFilePlayed ( std::string  file)
virtual

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
[in]fileFile played successfully
virtual void telux::audio::IPlayListListener::onPlaybackFinished ( )
virtual

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

class telux::audio::IAudioPlayer

This class 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 Member Functions

virtual telux::common::ErrorCode startPlayback (StreamConfig streamConfig, std::vector< PlaybackFile > &filesToPlay, std::weak_ptr< IPlayListListener > statusListener)=0
 
virtual telux::common::ErrorCode stopPlayback ()=0
 
virtual ~IAudioPlayer ()
 

Constructor & Destructor Documentation

virtual telux::audio::IAudioPlayer::~IAudioPlayer ( )
virtual

Destructor of the IAudioPlayer.

Member Function Documentation

virtual telux::common::ErrorCode telux::audio::IAudioPlayer::startPlayback ( StreamConfig  streamConfig,
std::vector< PlaybackFile > &  filesToPlay,
std::weak_ptr< IPlayListListener statusListener 
)
pure virtual

Plays audio files as specified in the playlist. The playlist can contain one or more files to play. How many times a file should be played can also be specified. If a file is played indefinitely, playback can be stopped by calling stopPlayback() at any time.

On platforms with access control enabled, the caller must have TELUX_AUDIO_PLAY, permission to invoke this method successfully.

Parameters
[in]streamConfigAudio stream parameters (format, sampling rate, devices etc.)
[in]filesToPlayList of files to play. They all must be of same format; for example; all PCM or all AMRWB.
[in]statusListenerReceives various status updates in IPlayListListener
Returns
telux::common::ErrorCode::SUCCESS, if the playback is started otherwise, an appropriate error code
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::ErrorCode telux::audio::IAudioPlayer::stopPlayback ( )
pure virtual

Stops the playback started with startPlayback().

On platforms with access control enabled, the caller must have TELUX_AUDIO_PLAY, permission to invoke this method successfully.

Returns
telux::common::ErrorCode::SUCCESS, if the playback is stopped. telux::common::ErrorCode::INVALID_STATE, if there is no playback in-progress. An appropriate error code in all other cases.
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.

Enumeration Type Documentation

Defines whether to play or skip this file.

Enumerator
COUNT 

Play the file for given number of times

INDEFINITELY 

Play the file indefinitely

SKIP 

Do not play the file