I want to use a ServerSocket at a PC
and a Socket for users
And I tried to Stream a music from Server to Client
But I dont know what should I send to the Client
Here's part of my code
What should I send? the <readByte> ? or the <lineWritten>
and a Socket for users
And I tried to Stream a music from Server to Client
But I dont know what should I send to the Client
Here's part of my code
Code:
public static void CP(File media , int LoopCount)
{
AudioInputStream AIS = null;
try
{
AIS = AudioSystem.getAudioInputStream(media);
}
catch(Exception e)
{
e.printStackTrace();
}
if (AIS != null)
{
AudioFormat format = AIS.getFormat();
System.out.println(format.toString());
SourceDataLine line = null ;
try
{
line = AudioSystem.getSourceDataLine(format);
}
catch(Exception ex){}
byte[] abData = new byte[128000];
int readByte = 0;
while(readByte != -1)
{
try
{
readByte = AIS.read(abData, 0, abData.length);
ops.write(new byte[readByte]);
if(readByte > 0)
{
line.open(format);
line.start();
int lineWritten = line.write(abData,0,readByte);
//System.out.println(readByte);
}
}
catch (LineUnavailableException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
Comment