reading a emdia file byte by byet and forward to VLC + JAVA
Posted: 07 Nov 2006 14:33
Hello i am trying to read a media file byte by byte, build UDP datagram and send this over my machine on port 5000. I started VLC player to listen on port 5000 UDP, VLC does receive something but does not display anything.
here is my java code:
I read an .avi file by chunck of 1024 bytes:
System.out.println("opening file: "+path+filename);
File file = new File(path+filename);
FileInputStream fin = new FileInputStream(file);
DatagramSocket udpsocket = new DatagramSocket();
udpsocket.setSendBufferSize(1024);
DatagramPacket packet;
byte b[] = new byte[1024];
int i = 0;
while(fin.read(b) != -1){
i++;
packet = new DatagramPacket(b,b.length);
packet.setAddress(InetAddress.getByName("localhost"));
packet.setPort(5000);
System.out.println("send packet "+ i);
udpsocket.send(packet);
b = new byte[1024];
}
udpsocket.close();
Could you please explain me what can be wrong in this?
thanks a lot
sebastien
here is my java code:
I read an .avi file by chunck of 1024 bytes:
System.out.println("opening file: "+path+filename);
File file = new File(path+filename);
FileInputStream fin = new FileInputStream(file);
DatagramSocket udpsocket = new DatagramSocket();
udpsocket.setSendBufferSize(1024);
DatagramPacket packet;
byte b[] = new byte[1024];
int i = 0;
while(fin.read(b) != -1){
i++;
packet = new DatagramPacket(b,b.length);
packet.setAddress(InetAddress.getByName("localhost"));
packet.setPort(5000);
System.out.println("send packet "+ i);
udpsocket.send(packet);
b = new byte[1024];
}
udpsocket.close();
Could you please explain me what can be wrong in this?
thanks a lot
sebastien