public void run() {
System.err.println("Processing the Events from the Thread");
// Process the events...
mediaPlayer.playMedia("udp://@:6666");
while(true){
Event event = gui.getClient().getNextEvent();
// System.err.println("Got " + event.getType());
switch(event.getType()){
case PUBLISHED_DATA:
// Subscriber receives event.
// is it the catalog?
if (Arrays.equals(event.getId(), gui.getVideoSubscriber().getCatalog())){
// Util.printBytes(event.getDataCopy());
// populate the catalog list.
gui.populateCatalogList(Util.getString(event.getDataCopy()));
event.freeNativeBuffer();
// finally unsubscribe to the catalog
gui.getVideoSubscriber().unsubscribeCatalog();
}else{
// Is a video
// get the packet and UDP it.
try {
byte [] buffer = event.getDataCopy();
DatagramPacket p = new DatagramPacket(buffer, buffer.length, InetAddress.getLocalHost(), 6666);
ds.send(p);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
event.freeNativeBuffer();
}
break;
}
}
}