Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open a Media from InputStream

 
Alessandro Ciccimarra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alessandro Ciccimarra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this could be a solution. Thank you very much. :-)
 
John Damien Smith
Ranch Hand
Posts: 260
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic