0

Audio playback. All the examples I've seen for Audio or Media in JavaFX8 have a source, either http: or file:. In my case the byte stream will be coming through as a ByteArrayInputStream. Ultimately I suspect this is what the Audio or Media class objects are processing. The source would start life as compressed audio where I would decompress it and then feed it to the Audio object. I am not seeing how to feed a byte array into a JavaFX audio object? Would someone please point me at a solution.

Thanks.

Walt Corey
  • 718
  • 7
  • 12
  • See: [RT-26823 Media should support InputStream](https://javafx-jira.kenai.com/browse/RT-26823), currently scheduled for implementation in Java 9. – jewelsea Apr 16 '15 at 17:42
  • thanks but that won't work. I need something now. I would think the constructor is invoked the file: object is turned into a stream and the stream is processed. That would argue there should be a constructor that takes a stream object. – Walt Corey Apr 16 '15 at 21:26
  • Sure, a input stream based constructor would be a useful feature, but it does not exist today. The only way I know to stream media to a JavaFX Media instance is to serve the content up using [http live streaming](http://en.wikipedia.org/wiki/HTTP_Live_Streaming). Alternately, JavaFX is open source and you could modify the source to accept (and appropriately process) an InputStream in the Media constructor. Or you could write the output of your decompressed audio to a file on disk or an [in memory file](https://github.com/google/jimfs), though at that point you aren't working with streams. – jewelsea Apr 16 '15 at 21:39
  • To understand the internal operation of the JavaFX media constructor better, read [Berry120's StackOverflow answer](http://stackoverflow.com/a/22563941/1155209). – jewelsea Apr 16 '15 at 21:43
  • I think maybe the way to approach this is using Java Sound, rather than JavaFS Audio, and use the SourseDataLine. As the streaming audio arrives from the Internet feed write the sampled audio into the SourceDataLine. If someone has already solved this use case, please let me know. Thanks. – Walt Corey Apr 16 '15 at 21:49
  • @jewelsea, I was typing my last and didn't see yours until I hit enter on mine. – Walt Corey Apr 16 '15 at 23:39

0 Answers0