Manevolent / ts3j

An open-source Java Teamspeak 3 client library using the TS3 full client protocol
Apache License 2.0
105 stars 15 forks source link

How to send Audio? #37

Closed KaratekHD closed 3 years ago

KaratekHD commented 3 years ago

Hello,

I do not quite understand how to send audio. Inside the README this code is given:

// Microphone interface
public void write(float[] buffer, int len) {
    byte[] opusPacket = doOpusEncodingHere(buffer, len);

    packetQueue.add(opusPacket);
}

@Override
public boolean isReady() {
    return true;
}

@Override
public CodecType getCodec() {
    return CodecType.OPUS_MUSIC;
}

@Override
public byte[] provide() {
    try {
        if (packetQueue.peek() == null)
        return new byte[0]; // underflow

        OpusPacket packet = packetQueue.remove();

        if (packet == null)
        return new byte[0]; // underflow

        return packet.getBytes();
    } catch (NoSuchElementException ex) {
        return new byte[0]; // signals the decoder on the clients to stop
    }
}

But how would I connect this/use it? I just do not understand how this is supposed to work. Thank you

~Jens

Manevolent commented 3 years ago

Sending audio is documented in a couple places, see:

https://github.com/Manevolent/ts3j-musicbot or https://github.com/Manevolent/manebot-ts3

For partial and full framework examples