Methods Summary |
---|
private void | Fatal(java.lang.String name)
// Use reflection to get at the Log.
try {
if (errMeth == null) {
Class cls = Class.forName("com.sun.media.Log");
Class params[] = new Class []
{ Class.forName("java.lang.Object") };
errMeth = cls.getMethod("error", params);
}
Object args[] = new Object [] { name };
errMeth.invoke(null, args);
} catch (Throwable t) {
System.err.println(name);
}
|
public void | addController(javax.media.Controller n)
try {
if (player != null) {
player.addController(n);
}
} catch (IncompatibleTimeBaseException e) {
Fatal(MediaPlayerResource.getString("PLAYER_NO_COMPATIBLE_TIME_BASE"));
return;
}
|
public void | addControllerListener(javax.media.ControllerListener listener)
if (player != null) {
player.addControllerListener(listener);
}
if (!controlListeners.contains(listener))
controlListeners.addElement(listener);
|
private void | addPopupMenu(java.awt.Component visual)addPopupMenu():
popup menu for some preset scales of the visualComponent
MenuItem mi;
ActionListener zoomSelect;
zoomMenu = new PopupMenu("Zoom");
zoomSelect = new popupActionListener();
visual.add(zoomMenu);
mi = new MenuItem("Scale 1:2");
zoomMenu.add(mi);
mi.addActionListener(zoomSelect);
mi = new MenuItem("Scale 1:1");
zoomMenu.add(mi);
mi.addActionListener(zoomSelect);
mi = new MenuItem("Scale 2:1");
zoomMenu.add(mi);
mi.addActionListener(zoomSelect);
mi = new MenuItem("Scale 4:1");
zoomMenu.add(mi);
mi.addActionListener(zoomSelect);
|
public void | addPropertyChangeListener(java.beans.PropertyChangeListener c)Adds a PropertyChangeListener to the listener list.
changes.addPropertyChangeListener(c);
|
private float | aspectRatio(float width, float height, int controllerHeight)aspectRatio():
calculate the aspect Ratio according to the width, height and control
component, MediaLocation text height if they exist
return (width/((float) (height-controllerHeight)));
|
private void | calculateSize()
if ( player == null )
return;
debug("claculateSize");
if (( visualComponent = player.getVisualComponent())!= null) {
// visualComponent.setSize(visualComponent.getPreferredSize());
preferredHeight =visualComponent.getPreferredSize().height;
preferredWidth =visualComponent.getPreferredSize().width;
}
if (((( controlComponent = player.getControlPanelComponent()) != null)&&
(isControlPanelVisible()))||(displayURL==true)) {
if ((controlComponent!=null)&& (isControlPanelVisible())) {
controlPanelHeight = controlComponent.getPreferredSize().height;
preferredHeight +=controlPanelHeight;
if (preferredWidth ==0)
preferredWidth = 320;
}
if (displayURL==true) {
urlFieldHeight = urlName.getPreferredSize().height;
preferredHeight +=urlFieldHeight;
}
}
if (visualComponent != null) {
Dimension vSize = visualComponent.getPreferredSize();
int totalHeight=0;
if (controlComponent != null) {
totalHeight+=controlComponent.getPreferredSize().height;
}
if (displayURL==true) {
totalHeight +=urlName.getPreferredSize().height;
}
if (( fixedAspectRatio==true) && (curZoomValue == 1.0)) {
//compare the ratio of parent and panel, and get the smaller number
if ((vSize.width!=0) &&(vSize.height!=0)) {
if (((float)getSize().width/(float)vSize.width) >=
((float)(getSize().height-totalHeight)/
(float)(vSize.height))) {
curZoomValue =
((float)(getSize().height-totalHeight)/
(float)(vSize.height));
} else {
curZoomValue =
((float)getSize().width/vSize.width);
}
}
if (curZoomValue <0.5)
curZoomValue=1;
}
if (newPanel !=null)
newPanel.setSize(visualComponent.getPreferredSize().width,
controlPanelHeight+urlFieldHeight);
}
|
private void | center(java.awt.Container parent, java.awt.Panel comp, boolean fit, int dheight)center():
This method moves the component to the center of parent
container. If fixAspectRatio is specified, then the width
and height will be adjusted accordingly.
int pwidth = parent.getSize().width;
int pheight = parent.getSize().height;
int width = comp.getSize().width;
int height = comp.getSize().height;
if (fit) {
float aspect = aspectRatio((float) width,(float) height, dheight);
if (width > pwidth) {
height = (int) ((float)pwidth/aspect) + dheight;
if (height > pheight) {
width = (int) (aspect*(pheight-dheight));
height = pheight;
} else
width = pwidth;
comp.setBounds(parent.getBounds().x,parent.getBounds().y,width,height);
} else if (height > pheight) {
width = (int) (aspect*(pheight-dheight));
height = pheight;
comp.setBounds(parent.getBounds().x,parent.getBounds().y,width,height);
}
}
comp.setLocation((pwidth/2)-(width/2), (pheight/2)-(height/2));
comp.setSize( width,height);
|
public void | close()
if (player != null) {
panel.removeAll();
player.close();
player = null;
} else {
return;
}
|
public void | deallocate()
if (player != null) {
debug("in deallocate");
player.deallocate();
} else {
return;
}
|
private void | debug(java.lang.String s)
// System.out.println(s);
|
private synchronized void | doRealize()doRealize(): internal function to get the visual, gain, control components and
add them to the panel of bean. If fixedAspectRatio is set, it will
check if Bean has more space to expand the visual component and calculate
the zoom factor.
debug("in doRealize");
if (player==null) {
Fatal(MediaPlayerResource.getString("SHOULD NOT OCCUR"));
System.exit(-1);
}
gainControl = player.getGainControl();
if (gainControl !=null) {
float re=gainControl.setLevel(curVolumeValue);
}
if (( visualComponent = player.getVisualComponent())!= null) {
vPanel = new Panel();
vPanel.setLayout( new BorderLayout() );
panel.setVisible(false);
visualComponent.setVisible(false);
vPanel.add("Center", visualComponent);
panel.add("Center", vPanel);
addComponentListener(new visualComponentAdapter(this));
addPopupMenu(visualComponent);
setPopupActive();
}
newPanel=new Panel();
newPanel.setLayout(new BorderLayout());
panel.add("South",newPanel);
urlName = new TextField(10);
urlName.setEditable(false);
if (displayURL==true) {
urlName.setText(urlString);
newPanel.add("South",urlName);
}
if ((( controlComponent = player.getControlPanelComponent()) != null)&&
(isControlPanelVisible())) {
controlComponent.setVisible(false);
newPanel.add("North",controlComponent);
}
calculateSize();
if (visualComponent == null) {
if (controlComponent !=null)
panel.setSize(controlComponent.getPreferredSize().width,
controlPanelHeight+urlFieldHeight );
else
panel.setSize(100,urlFieldHeight);
}
showVisual();
|
public javax.media.Control | getControl(java.lang.String forName)
if (player != null) {
return player.getControl(forName);
} else {
return null;
}
|
public java.awt.Component | getControlPanelComponent()
if (player != null) {
return player.getControlPanelComponent();
}
return null;
|
public int | getControlPanelHeight()Gets the height of the control Component for this MediaPlayer .
if (isControlPanelVisible())
return controlPanelHeight;
else
return 0;
|
public javax.media.Control[] | getControls()
if (player != null) {
return player.getControls();
} else {
return new Control[0];
}
|
public javax.media.Time | getDuration()
if (player != null) {
return player.getDuration();
} else {
return DURATION_UNKNOWN;
}
|
public javax.media.GainControl | getGainControl()
if (player != null) {
return player.getGainControl();
}
return null;
|
public java.lang.String | getMediaLocation()Gets the value of the media location property for this MediaPlayer .
if (mrl !=null) {
return mrl.toString();
} else {
return urlString;
}
|
public int | getMediaLocationHeight()Gets the height of the media-location text field for this MediaPlayer .
if (isMediaLocationVisible())
return urlFieldHeight;
else
return 0;
|
protected javax.media.MediaLocator | getMediaLocator(java.lang.String filename)Gets a MediaLocator for this MediaPlayer
that corresponds to the specified String .
MediaLocator localml = null;
if (filename.regionMatches(true, 0, "<codebase>", 0, 10)) {
try {
if (mpCodeBase == null)
initSetCodeBase();
localml = new MediaLocator( new URL(mpCodeBase, filename.substring(11)));
} catch (java.net.MalformedURLException e) {
if (mpCodeBase != null ) {
log(MediaPlayerResource.getString("NO IMAGE:BAD_URL")+
filename+" " + mpCodeBase);
urlString = " ";
}
return null;
}
} else {
localml = new MediaLocator(filename);
}
return localml;
|
public long | getMediaNanoseconds()Gets the current media time in nanoseconds.
if (player != null) {
return player.getMediaNanoseconds();
} else {
return Long.MAX_VALUE;
}
|
public javax.media.Time | getMediaTime()
if (player != null) {
return player.getMediaTime();
} else {
return LATENCY_UNKNOWN;
}
|
public boolean | getPlaybackLoop()Gets the loop property for this MediaPlayer . This property indicates
whether the MediaPlayer should play the media stream
repeatedly or stop when the end of media is reached.
return looping;
|
public javax.media.Player | getPlayer()Gets the current Player for this MediaPlayer .
return player;
|
public java.awt.Dimension | getPreferredSize()Gets the dimensions of the preferred size.
return new Dimension(preferredWidth, preferredHeight);
|
public float | getRate()
if (player != null) {
return player.getRate();
} else {
return 0.0f;
}
|
public javax.media.Time | getStartLatency()
if (player != null) {
return player.getStartLatency();
} else {
return LATENCY_UNKNOWN;
}
|
public int | getState()
if (player != null) {
return player.getState();
} else {
return Controller.Unrealized;
}
|
public javax.media.Time | getStopTime()
if (player != null) {
return player.getStopTime();
} else {
return null;
}
|
public javax.media.Time | getSyncTime()
if (player != null) {
return player.getSyncTime();
} else {
return LATENCY_UNKNOWN;
}
|
public int | getTargetState()
if (player != null) {
return player.getTargetState();
} else {
return Controller.Unrealized;
}
|
public javax.media.TimeBase | getTimeBase()
if (player != null) {
return player.getTimeBase();
} else {
return null;
}
|
public java.awt.Component | getVisualComponent()
if (player != null) {
return player.getVisualComponent();
}
return null;
|
public java.lang.String | getVolumeLevel()Gets the audio volume property for this MediaPlayer .
The volume can range from zero to five, where zero is silence
and five is the maximum volume.
return this.curVolumeLevel;
|
public java.lang.String | getZoomTo()Gets the zoom property for this MediaPlayer . This property specifies
a scale factor for the visual components.
return this.curZoomLevel;
|
private void | initSetCodeBase()initSetCodeBase():
set codebase for relative media location.
if (mpCodeBase!=null)
return;
Container p = getParent();
while (p!=null) {
if (p instanceof Applet)
break;
p = p.getParent();
}
if (p!=null) {
setCodeBase(((Applet)p).getCodeBase());
mpAppletContext = ((java.applet.Applet) p).getAppletContext();
}
|
public boolean | isCachingControlVisible()Gets the caching control visibility property for this MediaPlayer .
This property indicates whether or not the caching control is displayed at runtime.
The caching control displays the download progress for media accessed over the network.
return cachingVisible;
|
public boolean | isControlPanelVisible()Gets the control panel visibility property for this MediaPlayer .
This property indicates whether or not the control panel is visible at runtime.
return panelVisible;
|
public boolean | isFixedAspectRatio()Gets the fixed aspect ratio property for this MediaPlayer . This
property indicates whether or not the aspect ratio of the video
is maintained when the visual component is resized.
return fixedAspectRatio;
|
public boolean | isMediaLocationVisible()Gets the MediaLocationVisible property for this MediaPlayer .
return displayURL;
|
public boolean | isPlayBackLoop()Gets the loop property for this MediaPlayer . This property indicates
whether the MediaPlayer should play the media stream
repeatedly or stop when the end of media is reached.
return looping;
|
private void | log(java.lang.String name)
// Use reflection to get at the Log.
try {
if (errMeth == null) {
Class cls = Class.forName("com.sun.media.Log");
Class params[] = new Class []
{ Class.forName("java.lang.Object") };
errMeth = cls.getMethod("comment", params);
}
Object args[] = new Object [] { name };
errMeth.invoke(null, args);
} catch (Throwable t) {
System.err.println(name);
}
|
public javax.media.Time | mapToTimeBase(javax.media.Time t)
try {
if (player != null) {
return player.mapToTimeBase(t);
}
} catch (ClockStoppedException e) {
log(MediaPlayerResource.getString("CALL_A_STOPPED_CLOCK"));
}
return LATENCY_UNKNOWN;
|
public void | prefetch()
if (player != null) {
player.prefetch();
} else {
return;
}
|
public void | readExternal(java.io.ObjectInput in)Restores the contents of this object
//save the component state
setBounds((Rectangle)in.readObject());
setBackground((Color) in.readObject());
setForeground((Color) in.readObject());
setFont((Font) in.readObject());
setVisible(in.readBoolean());
setEnabled(in.readBoolean());
//restore MediaPlayer state
String n = (String)(in.readObject());
if (n != null) {
mrl = new MediaLocator(n);
}
if (mrl !=null) {
try {
setMediaLocator(mrl);
} catch (Exception e) { }
}
setMediaLocationVisible(in.readBoolean());
panelVisible = in.readBoolean();
cachingVisible = in.readBoolean();
fixedAspectRatio = in.readBoolean();
preferredHeight = in.readInt();
preferredWidth = in.readInt();
//restore Player state if appropriate
if (in.readBoolean()) {
int s = in.readInt();
int ts = in.readInt();
state = Unrealized;
if (s >= Realized) {
long mt = in.readLong();
long st = in.readLong();
float r = in.readFloat();
if (ts >= Prefetched) {
player.prefetch();
waitForState(Prefetched);
} else if (ts >= Realized) {
player.realize();
waitForState(Realized);
}
player.setMediaTime(new Time(mt));
player.setStopTime(new Time(st));
player.setRate(r);
float l = in.readFloat();
if (l != -1.0F) {
GainControl g = player.getGainControl();
if (g != null) {
boolean mute = in.readBoolean();
g.setLevel(l);
g.setMute(mute);
} else {
in.readBoolean();
}
}
if (ts >= Started) {
player.start();
}
}
}
invalidate();
validate();
|
public void | realize()
if (player != null) {
player.realize();
} else {
return;
}
|
public void | removeController(javax.media.Controller old)
if (player != null) {
player.removeController(old);
}
|
public void | removeControllerListener(javax.media.ControllerListener listener)
if (player != null) {
player.removeControllerListener(listener);
}
if (controlListeners.contains(listener)) {
controlListeners.removeElement(listener);
}
|
public void | removePropertyChangeListener(java.beans.PropertyChangeListener c)Removes a PropertyChangeListener from the listener list.
changes.removePropertyChangeListener(c);
|
public void | restoreMediaTime()Restores the media time saved by saveMediaTime
so that the video resumes from the time it was stoped.
setMediaTime(mediaTime);
|
public void | saveMediaTime()Saves the media stop time to a variable.
mediaTime = getMediaTime();
|
public void | setBounds(int x, int y, int w, int h)Resizes the visual Component , control Component ,
and urlName according to the specified dimensions.
debug("setBounds "+x +" "+y+" "+w+" "+h+" ");
super.setBounds(x,y,w,h);
Dimension d = getSize();
int pheight = d.height;
int pwidth = d.width;
int p = 0;
int totalHeight = 0;
if ((urlName!=null) &&(isMediaLocationVisible())) {
totalHeight = urlFieldHeight=urlName.getPreferredSize().height;
if ((pheight < 5) && (displayURL==true)) {
pheight = 5;
}
}
if ((controlComponent != null) && isControlPanelVisible()) {
controlPanelHeight=controlComponent.getPreferredSize().height;
totalHeight +=controlPanelHeight;
if (d.width < 160)
d.width = 160;
if ((pheight < 2) && (visualComponent != null))
{
pheight += 2;
}
}
if (visualComponent !=null) {
Dimension vSize = visualComponent.getPreferredSize();
if (fixedAspectRatio == true) {
//compare the ratio of parent and panel, and get the smaller number
if (((float)pwidth/(float)vSize.width) >=
((float)(pheight-totalHeight)/
(float)(vSize.height-totalHeight)))
curZoomValue =
((float)(pheight-totalHeight)/
(float)(vSize.height-totalHeight));
else
curZoomValue = (float)pwidth/(float)vSize.width;
if (curZoomValue <1.0)
curZoomValue=1;
zoomTo(curZoomValue);
} else
panel.setBounds(getBounds());
} else {
panel.setSize(getSize());
validate();
}
|
public void | setCachingControlVisible(boolean isVisible)Sets the caching control visibility property for this MediaPlayer .
This property indicates whether or not the caching control is displayed at runtime.
The caching control displays the download progress for media accessed over the network.
if (cachingVisible != isVisible) {
boolean old = cachingVisible;
if (cachingComponent != null) {
if (isVisible) {
panel.add("South", cachingComponent);
} else {
panel.remove(cachingComponent);
}
}
invalidate();
validate();
changes.firePropertyChange("cachingControlVisible", new Boolean(old),
new Boolean(cachingVisible));
}
cachingVisible = isVisible;
|
public void | setCodeBase(java.net.URL cb)Sets the codebase of the running applet.
mpCodeBase = cb;
|
public void | setControlPanelVisible(boolean isVisible)Sets the control panel visibility property for this MediaPlayer .
This property indicates whether or not the control panel is displayed at runtime.
if (panelVisible != isVisible) {
boolean old=panelVisible;
if (controlComponent != null) {
if (isVisible) {
panel.add("South", controlComponent);
} else {
panel.remove(controlComponent);
}
}
invalidate();
validate();
panelVisible = isVisible;
changes.firePropertyChange("controlPanelVisible", new Boolean(old),
new Boolean(panelVisible));
}
|
public void | setDataSource(javax.media.protocol.DataSource ds)Sets the DataSource for this MediaPlayer . This
method creates a Player for the specified DataSource .
If a Player already exists for this MediaPlayer ,
this method stops that Player and releases all
of the resources it is using. Then a new Player is created with
the specified DataSource .
All controller listeners registered for the old
Player are added to the listener list of the new Player .
try {
debug("setDataSource");
if (ds != null) {
if (panel != null)
panel.removeAll();
if (player != null) {
player.stop();
if (controlListeners.contains(selfListener))
controlListeners.removeElement(selfListener);
}
}
if (urlName !=null) {
if (ds.getLocator()!=null)
urlName.setText(ds.getLocator().toExternalForm());
else
urlName.setText("");
urlName.setFont(getFont());
}
try {
player = javax.media.Manager.createPlayer(ds);
} catch (Exception e) {
player = null;
urlString = " ";
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
}
if (player==null) {
return;
}
if (ds.getLocator()!=null)
urlString = ds.getLocator().toExternalForm();
else
urlString = "";
player.addControllerListener(selfListener=new InternalControllerAdapter(this));
if (!controlListeners.isEmpty()) {
for (int i=0;i<controlListeners.size();i++)
player.addControllerListener(
(ControllerListener)controlListeners.elementAt(i));
}
} catch (Exception e) {
mrl = null;
e.printStackTrace();
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
}
|
public void | setFixedAspectRatio(boolean isFixed)Sets the fixed aspect ratio property for this MediaPlayer . This
property indicates whether or not the aspect ratio of the video
is maintained when the visual component is resized.
boolean old = fixedAspectRatio;
fixedAspectRatio = isFixed;
changes.firePropertyChange("fixedAspectRatio", new Boolean(old),
new Boolean(fixedAspectRatio));
|
public void | setMediaLocation(java.lang.String location)Sets the media location property for this MediaPlayer .
This property specifies the location of the media file to be
presented by the MediaPlayer .
If a Player already exists for this MediaPlayer ,
this method stops that Player and releases all
of the resources it is using. Then a new Player is created to
present the specified media file.
All controller listeners registered for the old
Player are added to the listener list of the new Player .
try {
String old = "";
if (mrl !=null) {
old = mrl.toExternalForm();
if (panel != null)
panel.removeAll();
if (player != null) {
player.stop();
player.close();
panel.validate();
if (controlListeners.contains(selfListener))
controlListeners.removeElement(selfListener);
}
}
urlString = location;
if ((mrl = getMediaLocator(location))==null) {
//urlString = "";
return;
}
try {
player = javax.media.Manager.createPlayer(mrl);
} catch (Exception e) {
player = null;
urlString = " ";
changes.firePropertyChange("mediaLocation", location, old);
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
}
if (player==null) {
return;
}
if (urlName !=null) {
urlName.setText(urlString);
urlName.setFont(getFont());
}
player.addControllerListener(selfListener=new InternalControllerAdapter(this));
if (!controlListeners.isEmpty()) {
for (int i=0;i<controlListeners.size();i++)
player.addControllerListener(
(ControllerListener)controlListeners.elementAt(i));
}
changes.firePropertyChange("mediaLocation", old, location);
} catch (Exception e) {
mrl = null;
e.printStackTrace();
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
}
|
public void | setMediaLocationVisible(boolean val)Sets the MediaLocationVisible property for this MediaPlayer .
if (displayURL != val) {
if (urlName !=null) {
if (val) {
urlName.setText(urlString);
newPanel.add("South",urlName);
} else {
newPanel.remove(urlName);
}
}
panel.validate();
validate();
displayURL = val;
}
|
public void | setMediaLocator(javax.media.MediaLocator locator)Sets the MediaLocator for this MediaPlayer . This
method creates a Player for the specified MediaLocator .
If a Player already exists for this MediaPlayer ,
this method stops that Player and releases all
of the resources it is using. Then a new Player is created with
the specified MediaLocator .
All controller listeners registered for the old
Player are added to the listener list of the new Player .
try {
debug("setMediaLocator");
if (locator != null) {
if (mrl !=null) {
if (panel != null)
panel.removeAll();
if (player != null) {
player.stop();
player.close();
if (controlListeners.contains(selfListener))
controlListeners.removeElement(selfListener);
}
}
} else
return;
try {
player = javax.media.Manager.createPlayer(locator);
} catch (NoPlayerException e) {
player = null;
urlString = " ";
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
} catch (java.io.IOException e) {
player = null;
urlString = " ";
Fatal(MediaPlayerResource.getString("IO_EXCEPTION")+e);
return;
}
if (player==null) {
return;
}
urlString = locator.toExternalForm();
mrl = locator;
if (urlName !=null) {
urlName.setText(urlString);
urlName.setFont(getFont());
}
player.addControllerListener(selfListener=new InternalControllerAdapter(this));
if (!controlListeners.isEmpty()) {
for (int i=0;i<controlListeners.size();i++)
player.addControllerListener(
(ControllerListener)controlListeners.elementAt(i));
}
} catch (Exception e) {
url = null;
e.printStackTrace();
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
}
|
public void | setMediaTime(javax.media.Time now)
if (player != null) {
player.setMediaTime(now);
}
|
public void | setPlaybackLoop(boolean val)Sets the loop property for this MediaPlayer . This property indicates
whether the MediaPlayer should play the media stream
repeatedly or stop when the end of media is reached.
boolean old = looping;
looping = val;
changes.firePropertyChange("playbackLoop", new Boolean(old),
new Boolean(looping));
|
public void | setPlayer(javax.media.Player newPlayer)Specifies an existing Player to use to present media
for this MediaPlayer .
If a Player already exists for this MediaPlayer ,
this method stops that Player and releases all
of the resources it is using.
All controller listeners registered for the old
Player are added to the listener list of the new Player .
debug("setPlayer");
if (newPlayer == null)
return;
if (newPlayer != null) {
if (panel != null)
panel.removeAll();
if (player != null) {
player.stop();
if (controlListeners.contains(selfListener))
controlListeners.removeElement(selfListener);
}
}
player=newPlayer;
urlString = "";
player.addControllerListener(selfListener=new InternalControllerAdapter(this));
switch(player.getState()) {
case (Prefetched):
debug("player state prefetched ");
break;
case (Prefetching):
debug("player state prefetching ");
break;
case (Realized):
debug("player state Realized ");
break;
case (Realizing):
debug("player state Realizing");
break;
case (Started):
debug("player state started ");
break;
case (Unrealized):
debug("player state Unrealized ");
break;
}
if ((player.getState()==Realized) ||
(player.getState()==Prefetching))
doRealize();
if ((player.getState()==Prefetched) ||
(player.getState()==Started)) {
doRealize();
//doPrefetch();
}
if (!controlListeners.isEmpty()) {
for (int i=0;i<controlListeners.size();i++)
player.addControllerListener(
(ControllerListener)controlListeners.elementAt(i));
}
|
public void | setPopupActive(boolean isActive)Specifies whether or not the Zoom Popup Menu is active.
If setPopupActive is set to false, the popup menu won't be created.
if (isActive !=isPopupActive) {
isPopupActive = isActive;
setPopupActive();
}
|
private void | setPopupActive()Private class activate popup according to private variable isPopupActive.
if (isPopupActive ==true)
visualComponent.addMouseListener( mouseListen= new visualMouseAdapter());
else if(mouseListen!=null)
visualComponent.removeMouseListener( mouseListen);
|
public float | setRate(float factor)
if (player != null) {
return player.setRate(factor);
} else {
return 0.0f;
}
|
public void | setSource(javax.media.protocol.DataSource data)
try {
if (player != null) {
player.setSource(data);
}
} catch (IOException e) {
Fatal(MediaPlayerResource.getString("IO_EXCEPTION")+e);
return;
} catch (IncompatibleSourceException e) {
Fatal(MediaPlayerResource.getString("INCOMPATIBLE_SOURCE_EXCEPTION") + e);
return;
}
|
public void | setStopTime(javax.media.Time stopTime)
if (player != null) {
player.setStopTime(stopTime);
}
|
public void | setTimeBase(javax.media.TimeBase master)
try {
if (player != null) {
player.setTimeBase(master);
}
} catch (IncompatibleTimeBaseException e) {
Fatal(MediaPlayerResource.getString("INCOMPATIBLE_TIME_BASE")+e);
return;
}
|
public void | setVolumeLevel(java.lang.String volumeString)Sets the audio volume property for this MediaPlayer .
The volume can range from zero to five, where zero is silence
and five is the maximum volume.
debug("in setVolumeLevel");
if (volumeString == null) {
return;
}
String old = curVolumeLevel;
int level = Integer.parseInt(volumeString);
curVolumeLevel = volumeString;
curVolumeValue = level * 0.2f;
if (gainControl != null)
gainControl.setLevel(curVolumeValue);
changes.firePropertyChange("volumeLevel", old, curVolumeLevel);
|
public void | setZoomTo(java.lang.String scale)Sets the zoom property for this MediaPlayer . This property specifies
a scale factor for the visual components. When zoom is called, the
visual components are resized accordingly.
debug("setZoomTo");
curZoomLevel = scale;
if (scale.trim().equals(MediaPlayerResource.getString("1:2"))) {
curZoomValue = 0.5f;
} else if (scale.trim().equals(MediaPlayerResource.getString("1:1"))) {
curZoomValue = 1.0f;
} else if (scale.trim().equals(MediaPlayerResource.getString("2:1"))) {
curZoomValue = 2.0f;
} else if (scale.trim().equals(MediaPlayerResource.getString("4:1"))) {
curZoomValue = 4.0f;
}
fixtedFirstTime=false;
zoomTo(curZoomValue);
|
private synchronized void | showVisual()
//debug(" doPrefetch");
if (cachingComponent!=null) {
panel.remove(cachingComponent);
validate();
}
if ((visualComponent!=null) &&
((fixedAspectRatio==true) || (fixtedFirstTime==false))) {
zoomTo(curZoomValue);
} else {
panel.setSize(getSize());
}
panel.setVisible(true);
if (visualComponent != null) {
visualComponent.setVisible(true);
}
if ((controlComponent != null)&& (isControlPanelVisible())) {
controlComponent.setVisible(true);
}
panel.validate();
validate();
|
public void | start()Starts the MediaPlayer as soon as possible. If the MediaPlayer does
not already have a Player ,
it creates one and then
starts it.
if (player != null) {
player.start();
} else {
if (mrl ==null) {
initSetCodeBase();
mrl=getMediaLocator(urlString);
}
if (mrl !=null) {
try {
player = javax.media.Manager.createPlayer(mrl);
player.addControllerListener(selfListener =
new InternalControllerAdapter(this));
start();
//add original list to new player
if (controlListeners.size()>0) {
for (int i=0;i<controlListeners.size();i++)
player.addControllerListener(
(ControllerListener)controlListeners.elementAt(i));
}
} catch (Exception e) {
player= null;
urlString = " ";
Fatal(MediaPlayerResource.getString("UNABLE_CREATE_PLAYER")+e);
return;
}
} else
Fatal(MediaPlayerResource.getString("COULD_NOT_START_PLAYER"));
}
|
public void | stop()
if (player != null) {
player.stop();
}
|
public void | stopAndDeallocate()Stops the clock and deallocates the system resources used by this
player.
if (player != null) {
player.stop();
}
|
public void | syncStart(javax.media.Time at)
debug("syncStart ");
if (player != null) {
player.syncStart(at);
}
|
public synchronized void | waitForState(int s)Ensures the ability to synchronously
change state. Supports serialization.
while (state != s) {
try {
wait(1000);
} catch (Exception e) {}
}
|
public void | writeExternal(java.io.ObjectOutput out)Saves the contents of this object by calling the ObjectOutput
writeObject method.
//save the component state
out.writeObject(getBounds());
out.writeObject(getBackground());
out.writeObject(getForeground());
out.writeObject(getFont());
out.writeBoolean(isVisible());
out.writeBoolean(isEnabled());
//save the MediaPlayer state
if (mrl !=null) {
out.writeObject(mrl.toExternalForm());
} else {
out.writeObject(null);
}
out.writeBoolean(displayURL);
out.writeBoolean(panelVisible);
out.writeBoolean(cachingVisible);
out.writeBoolean(fixedAspectRatio);
out.writeInt(preferredHeight);
out.writeInt(preferredWidth);
//save the Player state if appropriate
if (player == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeInt(player.getState());
out.writeInt(player.getTargetState());
if (player.getState() >= Realized) {
out.writeLong(player.getMediaNanoseconds());
out.writeLong(player.getStopTime().getNanoseconds());
out.writeFloat(player.getRate());
//we need to save Gain information:
GainControl g;
if ((g = player.getGainControl()) != null) {
out.writeFloat(g.getLevel());
out.writeBoolean(g.getMute());
} else {
out.writeFloat(-1.0F);
}
}
}
|
private void | zoomTo(float z)zoomTo():
method to handle the resize of the visual component of a player
according to its input scale.
debug("zoomTo "+z);
int ddwidth=0;
int ddheight=0;
if ((visualComponent != null) && fitVideo) {
try {
Dimension d=visualComponent.getPreferredSize();
ddwidth = (int)(d.width * z);
ddheight = (int)(d.height * z);
int dheight=0;
if ((controlComponent != null) && isControlPanelVisible())
dheight = controlComponent.getPreferredSize().height;
if (displayURL ==true)
dheight += urlName.getPreferredSize().height;
if (newPanel!=null)
newPanel.setSize(ddwidth,dheight);
panel.setSize(ddwidth , ddheight+dheight );
if ((fixedAspectRatio ==true) ||
((fixedAspectRatio==false)&&(fixtedFirstTime==false)))
center(this,panel,true,dheight);
else
center(this,panel,false,dheight);
panel.validate();
} catch (Exception e) {
log(MediaPlayerResource.getString("UNABLE_TO_ZOOM")+e);
}
}
|