ReSpeak / tsclientlib

A TeamSpeak3 protocol implementation for usage in clients and bots
Apache License 2.0
121 stars 15 forks source link

How to play a wav file? #28

Closed xstater closed 2 years ago

xstater commented 2 years ago

I want to build a simple bot to play some sound in my ts server. I noticed that there is a ts3client_playWaveFile api in ts SDK, but i didn't see the same api in tsclientlib. So how to do that ?

Flakebi commented 2 years ago

tsclientlib contains code to send audio packets, but not to create them. You need to write that code yourself. I.e. read the wav file, encode it with some opus library like audiopus, manage the timing on when to send packets, and send them off as audio packets with tsclientlib.

There is some example code in https://github.com/ReSpeak/tsclientlib/blob/master/tsclientlib/examples/audio.rs and https://github.com/ReSpeak/tsclientlib/blob/master/tsclientlib/examples/audio_utils/audio_to_ts.rs that captures microphone input with SDL and sends that (it doesn’t need to do any timing). If you’re looking for a bot to play music, you might find https://github.com/Splamy/TS3AudioBot interesting.

xstater commented 2 years ago

wow, thanks for for your response! I will look these documents