📄 nativemediaplayerwindowsqt.java
字号:
/** * Stop the media player */ public synchronized void stop() { automation.invoke("Stop"); stopControllers(); // double rate = ((Variant) automation.invoke("GetRate")).getFltVal().getValue(); while (getRate() > 0) { try { Thread.sleep(100); // rate = ((Variant) automation.invoke("GetRate")).getFltVal().getValue(); // System.out.println("sleep stop"); } catch (Exception e) { } } playing = false; } /** * Tell if this player is playing * * @return DOCUMENT ME! */ public boolean isPlaying() { return playing; } /** * DOCUMENT ME! * * @return the step size for one frame */ public long getMilliSecondsPerSample() { return millisPerSample; } /** * DOCUMENT ME! * * @param milliSeconds the step size for one frame */ public void setMilliSecondsPerSample(long milliSeconds) { millisPerSample = milliSeconds; } /** * Gets the volume as a number between 0 and 1 * is translated from 0 - 255 from QT * * @return DOCUMENT ME! */ public float getVolume() { float volume = ((Variant) automation.invoke("GetVolume")).getLVal() .getValue(); return volume / 255; } /** * Sets the volume as a number between 0 and 1 * is translated to 0 - 255 for QT * * @param level DOCUMENT ME! */ public void setVolume(float level) { automation.invoke("SetVolume", new Object[] { new Int32((int) (level * 255)) }); } /** * Set the offset to be used in get and set media time for this player * * @param offset the offset in milli seconds */ public void setOffset(long offset) { this.offset = offset; mediaDescriptor.timeOrigin = offset; } /** * DOCUMENT ME! * * @return the offset used by this player */ public long getOffset() { return offset; } /** * Sets the Clock's media time in milli seconds. is not synchronized in JMF * * @param time DOCUMENT ME! */ public synchronized void setMediaTime(long time) { if (isPlaying()) { stop(); } time = (long) (time * timeScale); if (time < 0) { time = 0; } System.out.println("SetTime " + time); automation.invoke("SetTime", new Object[] { new Int32((int) (time + offset)) }); setControllersMediaTime(time); } /** * DOCUMENT ME! */ public void nextFrame() { setMediaTime(getMediaTime() + getMilliSecondsPerSample()); } /** * DOCUMENT ME! */ public void previousFrame() { setMediaTime(getMediaTime() - getMilliSecondsPerSample()); } /** * Gets this Clock's current media time in milli seconds. * * @return DOCUMENT ME! */ public long getMediaTime() { long t = ((Variant) automation.invoke("GetTime")).getLVal().getValue(); t = (long) (0.5 + (t / timeScale)); return t - offset; } /** * Gets the current temporal scale factor. * * @return DOCUMENT ME! */ public float getRate() { return (float) ((Variant) automation.invoke("GetRate")).getFltVal() .getValue(); } /** * Sets the temporal scale factor (ignored). * * @param rate the playback rate */ public synchronized void setRate(float rate) { //stop(); //this.rate = rate; } /** * Returns false. * * @see mpi.eudico.client.annotator.player.ElanMediaPlayer#isFrameRateAutoDetected() */ public boolean isFrameRateAutoDetected() { return false; } /** * Get the duaspectRation of the media represented by this object in milli * seconds. * * @return DOCUMENT ME! */ public long getMediaDuration() { return duration; } /** * DOCUMENT ME! * * @param layoutManager DOCUMENT ME! */ public void setLayoutManager(ElanLayoutManager layoutManager) { if (this.layoutManager == null) { detachItem = new JMenuItem(ElanLocale.getString("Detachable.detach")); detachItem.addActionListener(this); popup.insert(detachItem, 0); } this.layoutManager = layoutManager; } /** * DOCUMENT ME! */ public void updateLocale() { infoItem.setText(ElanLocale.getString("Player.Info")); durationItem.setText(ElanLocale.getString("Player.duration") + ": " + TimeFormatter.toString(getMediaDuration())); if (detachItem != null) { if (detached) { detachItem.setText(ElanLocale.getString("Detachable.attach")); } else { detachItem.setText(ElanLocale.getString("Detachable.detach")); } } } /* * */ public void actionPerformed(ActionEvent e) { if (e.getSource().equals(detachItem) && (layoutManager != null)) { if (detached) { layoutManager.attach(getVisualComponent()); detachItem.setText(ElanLocale.getString("Detachable.detach")); detached = false; } else { layoutManager.detach(getVisualComponent()); detachItem.setText(ElanLocale.getString("Detachable.attach")); detached = true; } getVisualComponent().addNotify(); } else if (e.getSource() == infoItem) { new FormattedMessageDlg(this); } } /** * DOCUMENT ME! */ public void cleanUpOnClose() { // TODO Auto-generated method stub } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class VisualComponent extends Panel implements ComponentListener, HierarchyListener { /** * Creates a new VisualComponent instance */ public VisualComponent() { addComponentListener(this); addHierarchyListener(this); //setOpaque(false); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void componentResized(ComponentEvent e) { } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void hierarchyChanged(HierarchyEvent e) { System.out.println("hierar"); if (isDisplayable()) { System.out.println("disp"); oleContainer.doVerb(OleVerbs.SHOW); } } /** * DOCUMENT ME! */ public void addNotify() { System.out.println("addNotify"); super.addNotify(); oleContainer.doVerb(OleVerbs.SHOW); } /** * DOCUMENT ME! */ public void removeNotify() { System.out.println("removeNotify"); oleContainer.doVerb(OleVerbs.HIDE); super.removeNotify(); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void componentShown(ComponentEvent e) { System.out.println("compShown"); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void componentHidden(ComponentEvent e) { System.out.println("compHidden"); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void componentMoved(ComponentEvent e) { } } /* private class PlayerStateWatcher implements Runnable { public void run() { double rate = 0; do { try { Thread.sleep(100); rate = ((Variant) automation.invoke("GetRate")).getFltVal().getValue(); } catch (Exception e) { } } while (rate > 0); stop(); automation.invoke("SetEndTime", new Object[] {new Int32((int) (getMediaDuration() * timeScale))}); } } */ private class PlayerStateWatcher implements Runnable { /** * DOCUMENT ME! */ public void run() { // while (playing && getMediaTime() < stopTime) { // try { // Thread.sleep(200); // } catch (Exception e) { // e.printStackTrace(); // } // } // double rate = 0; do { try { Thread.sleep(100); // rate = ((Variant) automation.invoke("GetRate: " + rate)).getFltVal().getValue(); } catch (Exception e) { } } while (getRate() > 0); stop(); setStopTime((long) (getMediaDuration() * timeScale)); } } /** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */ private class MouseHandler extends MouseAdapter { /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void mouseClicked(java.awt.event.MouseEvent e) { if (e.getClickCount() >= 2) { if (layoutManager != null) { layoutManager.setFirstPlayer(NativeMediaPlayerWindowsQT.this); } return; } JPopupMenu.setDefaultLightWeightPopupEnabled(false); if (SwingUtilities.isRightMouseButton(e)) { popup.show(getVisualComponent(), e.getPoint().x, e.getPoint().y); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -