make a final pass to make sure we are not leaking memory. After that, I want to clean up the build system, and the samples. M build.xml - Call make export in mozilla directory - Fix clean target M mozilla/Makefile.in - Added export target M classes/org/mozilla/pluglet/PlugletLoader.java - avoid ambiguity by casting + CodeSource codesource = new CodeSource(url,(java.security.cert.Certificate []) null); M examples/MediaPlayer/JMPlayer.java - remove debug printfs M mozilla/npAPInsIInputStreamShim.cpp M mozilla/npAPInsIInputStreamShim.h - remove debug printfs - fix buffer allocation, refactor into its own method. - Use NPN_Mem* methods for memory allocation. - isolate lock access to private methods. Avoids locking when we already own the lock, which would cause an assertion. M mozilla/nppluglet.cpp - in dtor, check for null mScriptablePeer ivar before accessing it. M mozilla/nsScriptablePeer.cpp - whitespace M src/Pluglet.cpp - get the plugletEngine from do_GetService(). M src/PlugletEngine.cpp M src/PlugletFactory.cpp M src/PlugletLoader.cpp - remove debug printfs M test/test.java - added test finalize. build.xml classes/org/mozilla/pluglet/PlugletLoader.java examples/MediaPlayer/JMPlayer.java mozilla/Makefile.in mozilla/npAPInsIInputStreamShim.cpp mozilla/npAPInsIInputStreamShim.h mozilla/nppluglet.cpp mozilla/nsScriptablePeer.cpp src/Pluglet.cpp src/PlugletEngine.cpp src/PlugletFactory.cpp src/PlugletLoader.cpp test/test.java git-svn-id: svn://10.0.0.236/trunk@214609 18797224-902f-48f8-a5cc-f745e15eee43
135 lines
2.9 KiB
Java
135 lines
2.9 KiB
Java
import javax.media.*;
|
|
import javax.media.util.*;
|
|
import javax.media.format.*;
|
|
import javax.media.bean.playerbean.*;
|
|
import javax.media.control.*;
|
|
|
|
|
|
import org.mozilla.pluglet.*;
|
|
import org.mozilla.pluglet.mozilla.*;
|
|
import java.awt.*;
|
|
import java.awt.event.*;
|
|
import java.awt.print.*;
|
|
import java.io.*;
|
|
import java.util.*;
|
|
|
|
|
|
public class JMPlayer implements PlugletFactory {
|
|
public JMPlayer() {
|
|
}
|
|
public Pluglet createPluglet(String mimeType) {
|
|
Pluglet player = null;
|
|
try {
|
|
player = new Player();
|
|
}
|
|
catch (Throwable e) {
|
|
e.printStackTrace();
|
|
}
|
|
return player;
|
|
}
|
|
public void initialize(PlugletManager manager) {
|
|
}
|
|
public void shutdown() {
|
|
}
|
|
}
|
|
|
|
class Player implements Pluglet, ControllerListener {
|
|
Dimension defaultSize;
|
|
Frame frm;
|
|
int w, h;
|
|
MediaPlayer player = null;
|
|
Panel panel;
|
|
|
|
public synchronized void controllerUpdate(ControllerEvent ce) {
|
|
if(ce instanceof RealizeCompleteEvent) {
|
|
player.prefetch();
|
|
}
|
|
if(ce instanceof PrefetchCompleteEvent) {
|
|
Dimension dim = player.getPreferredSize();
|
|
frm.pack();
|
|
panel.setSize(dim);
|
|
frm.setSize(defaultSize);
|
|
player.start();
|
|
frm.show();
|
|
}
|
|
}
|
|
public Player() {
|
|
}
|
|
public void initialize(PlugletPeer peer) {
|
|
PlugletTagInfo2 info = (PlugletTagInfo2)peer.getTagInfo();
|
|
w = info.getWidth();
|
|
h = info.getHeight();
|
|
defaultSize = new Dimension(w, h);
|
|
}
|
|
public boolean playFile(String url) {
|
|
player.setMediaLocator(new MediaLocator(url));
|
|
if(player.getPlayer() == null) {
|
|
return false;
|
|
} else {
|
|
player.addControllerListener(this);
|
|
player.realize();
|
|
}
|
|
return true;
|
|
}
|
|
public void start() {
|
|
player = new MediaPlayer();
|
|
panel = new Panel();
|
|
panel.add(player);
|
|
}
|
|
public void stop() {
|
|
player.stop();
|
|
player.close();
|
|
}
|
|
public void destroy() {
|
|
}
|
|
public PlugletStreamListener newStream() {
|
|
JMPlayerStreamListener listener = new JMPlayerStreamListener();
|
|
listener.setPlayer(this);
|
|
return listener;
|
|
}
|
|
public void setWindow(Frame frame) {
|
|
if(frame == null) {
|
|
return;
|
|
}
|
|
frame.setSize(defaultSize);
|
|
frame.setLayout(new BorderLayout());
|
|
frame.add(panel);
|
|
frm = frame;
|
|
}
|
|
public void print(PrinterJob printerJob) {
|
|
}
|
|
}
|
|
|
|
class JMPlayerStreamListener implements PlugletStreamListener {
|
|
Player jmp;
|
|
|
|
public JMPlayerStreamListener() {
|
|
}
|
|
public void onStartBinding(PlugletStreamInfo streamInfo) {
|
|
if(!jmp.playFile(streamInfo.getURL())) {
|
|
System.out.println("Error starting player.");
|
|
return;
|
|
}
|
|
|
|
}
|
|
public void setPlayer(Player jmp) {
|
|
this.jmp = jmp;
|
|
}
|
|
public void onDataAvailable(PlugletStreamInfo streamInfo, InputStream input,int length) {
|
|
}
|
|
public void onFileAvailable(PlugletStreamInfo plugletInfo, String fileName) {
|
|
}
|
|
public void onStopBinding(PlugletStreamInfo plugletInfo,int status) {
|
|
}
|
|
public int getStreamType() {
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|