public void setMovie(URL path) { mp.setMediaLocator(new MediaLocator(path)); mp.realize(); fpc = null; revalidate(); // checkCEF(); }
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); }
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(); }
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(); }
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; } }
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."); } // } } } }
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; }
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; }
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(); }
public void goToEnd() { final Time dur = mp.getDuration(); if ((dur != Duration.DURATION_UNBOUNDED) && (dur != Duration.DURATION_UNKNOWN)) { setCurrentTime(dur.getSeconds()); } }
public void stop() { mp.stop(); }
public void setRate(float rate) { mp.setRate(rate); }
public void setFixedAspectRatio(boolean onOff) { mp.setFixedAspectRatio(onOff); revalidate(); // checkCEF(); }
public void setVolume(float linear) { final GainControl gc = mp.getGainControl(); if (gc != null) { gc.setLevel(linear); } }
public void setMuted(boolean muted) { final GainControl gc = mp.getGainControl(); if (gc != null) { gc.setMute(muted); } }
public void dispose() { if (oldSource != null) cef.removeSource(oldSource); mp.removeControllerListener(this); mp.stopAndDeallocate(); mp.close(); }
public void setLoopMode(boolean onOff) { mp.setPlaybackLoop(onOff); }
public void start() { mp.start(); }