File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JavaFX and the fly likes Open a Media from InputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Open a Media from InputStream" Watch "Open a Media from InputStream" New topic
Author

Open a Media from InputStream

Alessandro Ciccimarra
Greenhorn

Joined: Jan 18, 2012
Posts: 4
Hi guys,

as far as I know a Media object can only be created using an URI. I would like to read the media (audio) from a database as a stream and play it using the Media object.
How can it be done?

Thanks to all :-)
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

As the documentation here says that "The supplied URI must conform to RFC-2396 as required by java.net.URI." and when you look at the URI class for more details it supports FILE location. So a possible approach would be to fetch the media file and store it in a temp location and then use Media class.


Mohamed Sanaulla | My Blog
Alessandro Ciccimarra
Greenhorn

Joined: Jan 18, 2012
Posts: 4
Yes, this could be a solution. Thank you very much. :-)
John Damien Smith
Ranch Hand

Joined: Jan 26, 2012
Posts: 131
    
    9
You can also install your own urlhandler to create a custom protocol reader for the uri; e.g. db://myaudio.mp3
To do this you need to register a custom http://docs.oracle.com/javase/7/docs/api/java/net/URL.html#setURLStreamHandlerFactory%28java.net.URLStreamHandlerFactory%29
For details on how to do this see http://java.sun.com/developer/onlineTraining/protocolhandlers/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open a Media from InputStream
 
Similar Threads
How to record sound in a applet
Struts and Multimedia
Running media player from the program
Streaming Audo File, need to Stream only 30 seconds
How to reinvent Instant Messenger with Video?