Exemple #1
0
 public void setMovie(URL path) {
   mp.setMediaLocator(new MediaLocator(path));
   mp.realize();
   fpc = null;
   revalidate();
   //		checkCEF();
 }
Exemple #2
0
 public MovieView() {
   super(new BorderLayout(), false);
   setOpaque(true);
   mp = new MediaPlayer();
   mp.setPopupActive(false);
   mp.setFixedAspectRatio(false); // like cocoa player
   add(mp);
   cef = new ComponentEventForwarder(this);
   mp.addControllerListener(this);
 }
Exemple #3
0
 public void setControlPanelVisible(boolean onOff) {
   // System.err.println( "setControlPanelVisible( " + onOff + ") ");
   //		mp.setControlPanelVisible( !onOff );
   mp.setControlPanelVisible(onOff); // doesn't really show / hide it, thus ...
   mp.getControlPanelComponent()
       .setVisible(onOff); // ... hmmm, certainly we were not supposed to this
   //		mp.invalidate();
   //		mp.validate();
   revalidate();
   //		checkCEF();
 }
Exemple #4
0
 public void setToPreferredSize(float ratio) {
   // mp.isControlPanelVisible();
   final Dimension d = mp.getPreferredSize();
   setSize((int) (d.width * ratio + 0.5f), (int) (d.height * ratio + 0.5f));
   revalidate();
   //		checkCEF();
 }
Exemple #5
0
 private void checkCEF() {
   final Component newSource = mp.getVisualComponent();
   if (newSource != oldSource) {
     if (oldSource != null) cef.removeSource(oldSource);
     if (newSource != null) cef.addSource(newSource);
     oldSource = newSource;
   }
 }
Exemple #6
0
 public void setCurrentFrame(int frameIdx) {
   final FramePositioningControl fpc = getFramePosCtrl();
   if (fpc != null) {
     // f*****g scheiss don't work
     //			fpc.seek( frameIdx );
     // this don't work either. returns null
     final Time t = fpc.mapFrameToTime(frameIdx);
     // System.err.println( t );
     if ((t != null) && (t != Time.TIME_UNKNOWN)) {
       mp.setMediaTime(t);
     } else {
       // fobs is in fact so sucky, it will never do what JMF defines.
       // for example mapTimeToFrame returns 0 instead of FRAME_UNKNOWN
       // so it's comletely useless. bloody bastards.
       //				final int currentFrame = fpc.mapTimeToFrame( mp.getMediaTime() );
       //				if( currentFrame != FramePositioningControl.FRAME_UNKNOWN ) {
       //					System.err.println( "currentFrame = "+currentFrame+" so delta is " + (frameIdx -
       // currentFrame) );
       //					skip( frameIdx - currentFrame );
       //				} else { // ok, try the cheesy way
       final FrameRateControl frc = getFrameRateCtrl();
       if (frc != null) {
         float fps;
         fps = frc.getPreferredFrameRate();
         if (fps <= 0f) {
           fps = frc.getFrameRate() / mp.getRate();
         }
         if (fps > 0f) { // sucky fobs returns 0f instead of -1f!!!
           System.err.println(
               "frameIdx "
                   + frameIdx
                   + "; fps = "
                   + fps
                   + "; frameIdx / fps = "
                   + (frameIdx / fps));
           mp.setMediaTime(new Time(frameIdx / fps));
         }
       } else {
         System.err.println("MovieView.setCurrentFrame : N.A.");
       }
       //				}
     }
   }
 }
Exemple #7
0
  private FrameRateControl getFrameRateCtrl() {
    if (frc != null) return frc;

    final Control[] controls = mp.getControls();
    for (int i = 0; i < controls.length; i++) {
      if (controls[i] instanceof FrameRateControl) {
        frc = (FrameRateControl) controls[i];
        return frc;
      }
    }
    return null;
  }
Exemple #8
0
  private FramePositioningControl getFramePosCtrl() {
    if (fpc != null) return fpc;

    final Control[] controls = mp.getControls();
    for (int i = 0; i < controls.length; i++) {
      if (controls[i] instanceof FramePositioningControl) {
        fpc = (FramePositioningControl) controls[i];
        return fpc;
      }
    }
    return null;
  }
Exemple #9
0
 public void setCurrentTime(double seconds) {
   //		final boolean running = mp.getState() == Controller.Started;
   //		if( running ) mp.stop();
   mp.setMediaTime(new Time(seconds));
   //		if( running ) mp.start();
 }
Exemple #10
0
 public void goToEnd() {
   final Time dur = mp.getDuration();
   if ((dur != Duration.DURATION_UNBOUNDED) && (dur != Duration.DURATION_UNKNOWN)) {
     setCurrentTime(dur.getSeconds());
   }
 }
Exemple #11
0
 public void stop() {
   mp.stop();
 }
Exemple #12
0
 public void setRate(float rate) {
   mp.setRate(rate);
 }
Exemple #13
0
 public void setFixedAspectRatio(boolean onOff) {
   mp.setFixedAspectRatio(onOff);
   revalidate();
   //		checkCEF();
 }
Exemple #14
0
 public void setVolume(float linear) {
   final GainControl gc = mp.getGainControl();
   if (gc != null) {
     gc.setLevel(linear);
   }
 }
Exemple #15
0
 public void setMuted(boolean muted) {
   final GainControl gc = mp.getGainControl();
   if (gc != null) {
     gc.setMute(muted);
   }
 }
Exemple #16
0
 public void dispose() {
   if (oldSource != null) cef.removeSource(oldSource);
   mp.removeControllerListener(this);
   mp.stopAndDeallocate();
   mp.close();
 }
Exemple #17
0
 public void setLoopMode(boolean onOff) {
   mp.setPlaybackLoop(onOff);
 }
Exemple #18
0
 public void start() {
   mp.start();
 }