1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| void play(String url){
try{
System.out.println(url);
//travail sur le dur
//InputStream is=getClass().getResourceAsStream("/anovo/mpeg.mpeg");
try {
//player = Manager.createPlayer(is,"video/mpeg");
player = Manager.createPlayer(url);
//System.out.println(player.getContentType());
display.append("createPlayer() for "+url+" OK");
} catch (IOException ex) {
ex.printStackTrace();
display.append(ex.toString()+"\n");
display.append("createPlayer() for "+url+" FAILED");
} catch (MediaException ex) {
ex.printStackTrace();
display.append(ex.toString()+"\n");
display.append("createPlayer() for "+url+" FAILED");
}
try {
player.prefetch();
player.realize();
} catch (MediaException ex) {
ex.printStackTrace();
display.append("0: "+ex.toString()+"\n");
}
if (player.getContentType().substring(0,5).compareTo("audio")==0) {
try {
player.start();
display.append("Lecture...");
} catch (MediaException ex) {
ex.printStackTrace();
display.append(ex.toString());
}
}
if (player.getContentType().substring(0,5).compareTo("image")==0) {
display_image(player);
}
if (player.getContentType().substring(0,5).compareTo("video")==0) {
display_video(player);
}
} catch (Throwable et){
//exception générée par le mpeg capturée ici
et.printStackTrace();
display.append("1: "+et.toString()+"\n");
//reset();
}
}
private void display_image(Player p) {
try {
VideoControl vc;
// Grab the video control and set it to the current display.
vc = (VideoControl)p.getControl("VideoControl");
if (vc != null) {
//Form form = new Form("video");
display.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null));
//Display.getDisplay(this).setCurrent(form);
}
p.setLoopCount(-1);
p.start();
} catch (MediaException me) {
display.append(me.toString());
}
}
private void display_video(Player p) {
try {
VideoControl vc;
// Grab the video control and set it to the current display.
vc = (VideoControl)p.getControl("VideoControl");
if (vc != null) {
//Form form = new Form("video");
display.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null));
//Display.getDisplay(this).setCurrent(form);
}
p.start();
} catch (MediaException me) {
display.append("2"+me.toString());
}
} |
Partager