Playing wave files

The TeamSpeak Client Lib offers support to play wave files from the local harddisk.

Simple

To play a local wave file, call

unsigned int ts3client_playWaveFile(uint64 serverConnectionHandlerID, const char *path)

Play a local wave file on the playback device of the connection handler.

Parameters:
  • serverConnectionHandlerID – the connection handler on which to play the file. Effectively sets the playback device.

  • path – the full path of the wave file on the local file system

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason

Note

This is the simple version of playing a sound file. It’s a fire-and-forget mechanism, this function will not block.

Advanced

The more complex version is to play an optionally looping sound and obtain a handle, which can be used to pause, unpause and stop the loop.

Obtain handle

unsigned int ts3client_playWaveFileHandle(uint64 serverConnectionHandlerID, const char *path, int loop, uint64 *waveHandle)

Play a local wave file on the playback device of the connection handler.

This is a more advanced version of ts3client_playWaveFile as it gives you a handle which can be used to stop, pause, resume or even loop the wave file.

Parameters:
  • serverConnectionHandlerID – the connection handler on which to play the file. Effectively sets the playback device.

  • path – the full path of the wave file on the local file system

  • loop – Boolean value defining whether or not to loop the wave file until the handle is paused or stopped

  • waveHandle – address of a variable to receive the handle. Use the handle to stop, pause or resume the wave playback.

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason

Pause / resume

unsigned int ts3client_pauseWaveFileHandle(uint64 serverConnectionHandlerID, uint64 waveHandle, int pause)

Pauses or resumes playback of a wave file handle retrieved by ts3client_playWaveFileHandle.

Audio will be stopped at whatever location it is currently at and resumed from its paused location.

Parameters:
  • serverConnectionHandlerID – the connection handler on which the file is playing.

  • waveHandle – a wave handle on the specified connection handler as retrieved by ts3client_playWaveFileHandle

  • pause – Boolean value defining whether to pause or resume the waveHandle

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason

Close handle

unsigned int ts3client_closeWaveFileHandle(uint64 serverConnectionHandlerID, uint64 waveHandle)

Stops playback of, closes the wave file and invalidates the handle retrieved by ts3client_playWaveFileHandle.

Parameters:
  • serverConnectionHandlerID – the connection handler on which the file is playing.

  • waveHandle – a wave handle on the specified connection handler as retrieved by ts3client_playWaveFileHandle

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason