2002-11-14 21:13:08 +00:00
|
|
|
package org.thdl.media;
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
import java.applet.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.net.*;
|
|
|
|
import javax.media.*;
|
|
|
|
import netscape.javascript.JSObject;
|
|
|
|
import java.awt.*;
|
|
|
|
import org.thdl.savant.AnnotationPlayer;
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------*/
|
2002-11-15 20:38:25 +00:00
|
|
|
public class SmartApplet extends Applet implements AnnotationPlayer {
|
2002-11-14 21:13:08 +00:00
|
|
|
|
2002-11-15 20:38:25 +00:00
|
|
|
static public String FIC_SOUND;
|
2002-11-14 21:13:08 +00:00
|
|
|
private SmartJMFPlayer myJMFplayer;
|
2002-11-15 20:38:25 +00:00
|
|
|
|
2002-11-14 21:13:08 +00:00
|
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
public void init() {
|
|
|
|
FIC_SOUND = getParameter("Sound");
|
|
|
|
String TAB_STARTS = getParameter("STARTS");
|
|
|
|
String TAB_ENDS = getParameter("ENDS");
|
|
|
|
String TAB_IDS = getParameter("IDS");
|
|
|
|
|
|
|
|
myJMFplayer = new SmartJMFPlayer();
|
|
|
|
myJMFplayer.setParentContainer(this);
|
|
|
|
myJMFplayer.initForSavant(convertTimesForSmartMoviePanel(TAB_STARTS), convertTimesForSmartMoviePanel(TAB_ENDS), TAB_IDS);
|
2002-11-15 20:38:25 +00:00
|
|
|
myJMFplayer.addAnnotationPlayer(this);
|
2002-11-14 21:13:08 +00:00
|
|
|
setLayout(new BorderLayout());
|
|
|
|
add("Center", myJMFplayer);
|
|
|
|
}
|
2002-11-15 20:38:25 +00:00
|
|
|
/* public void stop() {
|
2002-11-14 21:13:08 +00:00
|
|
|
//player.close();
|
|
|
|
player.stop();
|
|
|
|
player.deallocate();
|
|
|
|
}*/
|
2002-11-15 20:38:25 +00:00
|
|
|
public void start() {
|
|
|
|
try {
|
|
|
|
myJMFplayer.loadMovie(new URL(FIC_SOUND));
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println(e.getMessage());
|
2002-11-14 21:13:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------*/
|
|
|
|
public boolean cmd_isRealized() {
|
|
|
|
return myJMFplayer.isInitialized();
|
|
|
|
}
|
|
|
|
public String cmd_firstS() {
|
|
|
|
return myJMFplayer.cmd_firstS();
|
|
|
|
}
|
|
|
|
public boolean cmd_stop() {
|
|
|
|
try {
|
|
|
|
myJMFplayer.cmd_stop();
|
|
|
|
return true;
|
|
|
|
} catch (SmartMoviePanelException err) {
|
|
|
|
System.out.println(err.getMessage());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public boolean cmd_isID(String theID) {
|
|
|
|
return myJMFplayer.cmd_isID(theID);
|
|
|
|
}
|
|
|
|
public boolean cmd_playFrom(String fromID) {
|
2002-11-15 20:38:25 +00:00
|
|
|
return myJMFplayer.cmd_playFrom(fromID);
|
2002-11-14 21:13:08 +00:00
|
|
|
}
|
|
|
|
public boolean cmd_playS(String fromID) {
|
|
|
|
return myJMFplayer.cmd_playS(fromID);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------*/
|
2002-11-15 20:38:25 +00:00
|
|
|
public void startAnnotation(String id) {
|
|
|
|
sendMessage("startplay", id);
|
|
|
|
}
|
|
|
|
public void stopAnnotation(String id) {
|
|
|
|
sendMessage("endplay", id);
|
2002-11-14 21:13:08 +00:00
|
|
|
}
|
|
|
|
private void sendMessage(String method, String mess) {
|
|
|
|
Object args[] = { mess };
|
|
|
|
try {
|
|
|
|
JSObject.getWindow(this).call(method, args);
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("Erreur appel javascript: "+e+" "+mess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------*/
|
2002-11-15 20:38:25 +00:00
|
|
|
private String convertTimesForSmartMoviePanel(String s) {
|
|
|
|
StringBuffer sBuff = new StringBuffer();
|
|
|
|
StringTokenizer sTok = new StringTokenizer(s, ",");
|
|
|
|
while (sTok.hasMoreTokens()) {
|
|
|
|
sBuff.append(String.valueOf(new Float(Float.parseFloat(sTok.nextToken()) * 1000).intValue()));
|
|
|
|
sBuff.append(',');
|
2002-11-14 21:13:08 +00:00
|
|
|
}
|
2002-11-15 20:38:25 +00:00
|
|
|
return sBuff.toString();
|
|
|
|
}
|
2002-11-14 21:13:08 +00:00
|
|
|
};
|