views:

634

answers:

2

Hey all, So ive got a need to play music files from a server on the network, in a java client app. I was thinking Sockets - have the server open a music file as a stream, and have the client connect to that and read & play it as an InputStream. Which would work - except AFAICS users wont be able to seek into the file(which they can currently for local Files), because I cant see how the Sockets stream can support that.

Any better ideas? Or a way to use the Sockets to seek?

JNI? I dont know enough about it to know if it would help.

The (totally lame) last resort is to use mapped network drives.

A: 

You'll need to define some sort of protocol that allows random access. The simplest solution would probably be to use HTTP and its "Range" header, and request the data in short pieces.

"Real" streaming protocols such as RTSP are a lot more complex and usually use UTP instead of TCP.

Michael Borgwardt
+2  A: 

Before you implement your own protocol, it would be worthwhile to take a look at the Java Media Framework. It supports streaming audio, video, etc. Here is the Wikipedia entry if you want a description written by humans.

Dave Ray
dalyons
Yeah, I was afraid of that. Typical Sun. JavaFX might be another option, but it will also probably be abandoned soon :)
Dave Ray