Audio sender and music player changes
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.manevolent</groupId>
|
<groupId>com.github.manevolent</groupId>
|
||||||
<artifactId>ffmpeg4j</artifactId>
|
<artifactId>ffmpeg4j</artifactId>
|
||||||
<version>1.0</version>
|
<version>534e72e6e7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
+1
-1
@@ -49,7 +49,7 @@ public class AudioSender {
|
|||||||
sink.write(thirtySecondsOfAudio, thirtySecondsOfAudio.length);
|
sink.write(thirtySecondsOfAudio, thirtySecondsOfAudio.length);
|
||||||
|
|
||||||
client.connect(
|
client.connect(
|
||||||
"your.teamspeak.server",
|
args[0],
|
||||||
10000L
|
10000L
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+18
-3
@@ -11,18 +11,29 @@ import com.github.manevolent.ts3j.util.Ts3Debugging;
|
|||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import static com.github.manevolent.ts3j.examples.audio.TeamspeakFastMixerSink.AUDIO_FORMAT;
|
import static com.github.manevolent.ts3j.examples.audio.TeamspeakFastMixerSink.AUDIO_FORMAT;
|
||||||
|
|
||||||
public class MusicPlayer {
|
public class MusicPlayer {
|
||||||
|
/**
|
||||||
|
* Example:
|
||||||
|
* java -jar jarfile.jar my.teamspeakserver.com some.mp3
|
||||||
|
*
|
||||||
|
* args[0] - TS3 server hostname (i.e. my.teamspeakserver.com)
|
||||||
|
* args[1] - Audio file path (accepts MP3, FLAC, WAV, you name it.) (i.e. some.mp3 or C:\some.mp3 or /home/you/some.mp3)
|
||||||
|
* @param args Arguments
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Ts3Debugging.setEnabled(false);
|
Ts3Debugging.setEnabled(false);
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
FFmpeg.register();
|
FFmpeg.register();
|
||||||
InputStream inputStream = new FileInputStream("bensound-ukulele.mp3");
|
InputStream inputStream = new FileInputStream(args[1]);
|
||||||
FFmpegInput input = new FFmpegInput(inputStream);
|
FFmpegInput input = new FFmpegInput(inputStream);
|
||||||
FFmpegSourceStream stream = input.open(FFmpeg.getInputFormatByName("mp3"));
|
FFmpegSourceStream stream = input.open(FFmpeg.getInputFormatByName("mp3"));
|
||||||
FFmpegAudioSourceSubstream audioSourceSubstream =
|
FFmpegAudioSourceSubstream audioSourceSubstream =
|
||||||
@@ -60,7 +71,7 @@ public class MusicPlayer {
|
|||||||
sink.start();
|
sink.start();
|
||||||
|
|
||||||
client.connect(
|
client.connect(
|
||||||
"your.teamspeak.server",
|
args[0],
|
||||||
10000L
|
10000L
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -89,13 +100,17 @@ public class MusicPlayer {
|
|||||||
if (currentFrame == null || frameOffset >= currentFrame.getLength()) {
|
if (currentFrame == null || frameOffset >= currentFrame.getLength()) {
|
||||||
if (frameQueue.peek() == null) {
|
if (frameQueue.peek() == null) {
|
||||||
try {
|
try {
|
||||||
frameQueue.addAll(resampleFilter.apply(audioSourceSubstream.next()));
|
AudioFrame frame = audioSourceSubstream.next();
|
||||||
|
Collection<AudioFrame> frameList = resampleFilter.apply(frame);
|
||||||
|
frameQueue.addAll(frameList);
|
||||||
} catch (EOFException ex) {
|
} catch (EOFException ex) {
|
||||||
// flush currentFrame
|
// flush currentFrame
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frameQueue.size() <= 0) continue;
|
||||||
|
|
||||||
currentFrame = frameQueue.remove();
|
currentFrame = frameQueue.remove();
|
||||||
frameOffset = 0;
|
frameOffset = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user