2

I've been looking around for quite some time to find a simple solution to the problem I am having.

Using Java, I'm trying to find a simple way to play the audio from a given YouTube URL to a selected audio mixer.

Looking around I see a few approaches, but they all appear to be missing an important aspect of what I'm looking for in one way or another

For example, using JavaFX or the JWebBrowser (in the DJ Native Swing library) both do not allow changing the audio output mixer, and the JavaFX browser no longer plays Youtube videos anyway.

I'd love to use the Java Sound API, as that allows audio mixer selection, but I don't really want to have to download the video, convert to wav, then play it. Using Java Sound is ideal if there is someway to steam the YouTube video audio to this API.

If you have any relatively straightforward way to play audio from a streamed YouTube video to a selectable audio device, please let me know.

Community
  • 1
  • 1
starwarswii
  • 2,187
  • 1
  • 16
  • 19
  • *"Using Java Sound is ideal if there is someway to steam the YouTube video audio to this API."* What format is the audio encoded in? Java Sound can play other audio types by adding a Service Provider Interface to decode them - there is an SPI available for MP3. – Andrew Thompson Aug 15 '15 at 12:08
  • @AndrewThompson I'm not sure. What format would be the easiest to get YouTube audio into? – starwarswii Aug 15 '15 at 16:29
  • *"What format would be the easiest to get YouTube audio into?"* One the Java Sound API already understands, would be *easiest.* – Andrew Thompson Aug 16 '15 at 01:33
  • @AndrewThompson how would I stream the audio from a YouTube video though Java Sound? – starwarswii Aug 16 '15 at 07:17
  • *"how would I stream the audio from a YouTube video"* I have no idea. I thought you already knew how to do that. – Andrew Thompson Aug 16 '15 at 07:54
  • @AndrewThompson nope. That's why I asked this question. – starwarswii Aug 16 '15 at 13:07
  • The official YouTube data API (v3) apparently doesn't let you stream/download any video. If you want to get audio streams you need to use third-party libraries. [Pafy](http://pythonhosted.org/Pafy/) lets you do just that... but it's Python. – approxiblue Sep 01 '15 at 03:31

0 Answers0