📄 jmstudio.java
字号:
openFile (); } else if ( strCmd.equals(MENU_FILE_OPENURL) ) { openUrl (); } else if ( strCmd.equals(MENU_FILE_OPENRTP) ) { openRtp (); } else if ( strCmd.equals(MENU_FILE_CAPTURE) ) { captureMedia (); } else if ( strCmd.equals(MENU_FILE_RECENTURL) ) { if ( objSource instanceof MenuItem ) { nameUrl = ((MenuItem)objSource).getLabel (); open ( nameUrl ); } } else if ( strCmd.equals(MENU_FILE_CLOSE) ) { killCurrentPlayer ();// setPlaceholder (); } else if ( strCmd.equals(MENU_FILE_EXPORT) ) { exportMedia (); } else if ( strCmd.equals(MENU_FILE_TRANSMIT) ) { transmitMedia (); } else if ( strCmd.equals(MENU_FILE_PREFERENCES) ) { if ( jmfRegistry == null ) jmfRegistry = new JMFRegistry (); jmfRegistry.setVisible ( true ); jmfRegistry.addWindowListener( new WindowAdapter () { public void windowClosing ( WindowEvent event ) { Vector vector; vector = CaptureDeviceManager.getDeviceList ( null ); if ( vector == null || vector.size() < 1 ) menuCapture.setEnabled ( false ); else menuCapture.setEnabled ( true ); } } ); } else if ( strCmd.equals(MENU_FILE_EXIT) ) { closeAll (); } else if ( strCmd.equals(MENU_PLAYER_AUTOPLAY) ) { } else if ( strCmd.equals(MENU_PLAYER_AUTOLOOP) ) { } else if ( strCmd.equals(MENU_PLAYER_KEEPASPECT) ) { } else if ( strCmd.equals(MENU_PLAYER_FULLSCREEN) ) { setFullScreen ( true ); } else if ( strCmd.equals(MENU_PLAYER_SNAPSHOT) ) { doSnapShot (); } else if ( strCmd.equals(MENU_PLAYER_PLUGINS) ) { if ( componentPlugins != null ) { componentPlugins.setVisible ( true ); } else { if ( controlPlugins != null && controlPlugins instanceof Component ) { componentPlugins = (Component)controlPlugins; componentPlugins.setVisible ( true ); component = componentPlugins; while ( component != null ) { if ( component instanceof Frame ) { frame = (Frame) component; JMFrame.autoPosition ( frame, this ); break; } component = component.getParent (); } } } } else if ( strCmd.equals(MENU_PLAYER_CAPTURE) ) { if ( dlgCaptureControls != null ) { dlgCaptureControls.setVisible ( true ); dlgCaptureControls.toFront (); } } else if ( strCmd.equals(MENU_PLAYER_RTPSESSION) ) { if ( dlgSessionControl != null ) { dlgSessionControl.setVisible ( true ); dlgSessionControl.toFront (); } } else if ( strCmd.equals(MENU_PLAYER_TRANSMISSION) ) { if ( dlgTransmissionStats != null ) { dlgTransmissionStats.setVisible ( true ); dlgTransmissionStats.toFront (); } } else if ( strCmd.equals(MENU_HELP_ABOUT) ) { AboutDialog.createDialog ( this ); } else { super.actionPerformed ( event ); } } public void itemStateChanged ( ItemEvent event ) { Object objSource; objSource = event.getSource (); if ( objSource == menuAutoPlay ) { if ( cfgJMApps != null ) cfgJMApps.setAutoPlay ( menuAutoPlay.getState() ); } else if ( objSource == menuAutoLoop ) { if ( mediaPlayerCurrent != null ) mediaPlayerCurrent.setPlaybackLoop ( menuAutoLoop.getState() ); if ( cfgJMApps != null ) cfgJMApps.setAutoLoop ( menuAutoLoop.getState() ); } else if ( objSource == menuKeepAspect ) { if ( mediaPlayerCurrent != null ) { mediaPlayerCurrent.setFixedAspectRatio ( menuKeepAspect.getState() ); if ( panelVideo != null ) panelVideo.resizeVisualComponent (); } if ( cfgJMApps != null ) cfgJMApps.setKeepAspectRatio ( menuKeepAspect.getState() ); } } public void windowClosing ( WindowEvent event ) { this.dispose (); } public void windowClosed ( WindowEvent event ) { int nIndex; Point pointLocation; super.windowClosed ( event ); if ( frameSnap != null ) frameSnap.dispose (); if ( vectorFrames.contains(this) ) { pointLocation = this.getLocation (); nIndex = vectorFrames.indexOf ( this ); if ( cfgJMApps != null ) cfgJMApps.setJMStudioFrameLocation ( pointLocation, nIndex ); vectorFrames.removeElement ( this ); } if ( vectorFrames.size() < 1 ) exitApllication (); } public synchronized void update ( ReceiveStreamEvent event) { ReceiveStream stream; SessionManager mngrSession; DataSource dataSource; PlayerFrame frame; if ( event instanceof NewReceiveStreamEvent ) { mngrSession = (SessionManager)event.getSource(); stream =((NewReceiveStreamEvent)event).getReceiveStream (); dataSource = stream.getDataSource (); strOptionalTitle = mngrSession.getSessionAddress().getDataAddress().getHostAddress() + ":" + mngrSession.getSessionAddress().getDataPort(); mngrSessionRtp = null; if ( vectorRtpFrames != null && vectorMngrSessions != null && vectorMngrSessions.size() > 0 && vectorMngrSessions.firstElement() == mngrSession ) { frame = new PlayerFrame ( this, strOptionalTitle ); vectorRtpFrames.addElement ( frame ); frame.open ( dataSource ); frame.setVisible ( true ); } else { open ( dataSource ); vectorMngrSessions = new Vector (); vectorMngrSessions.addElement ( mngrSession ); vectorStreams = new Vector (); vectorStreams.addElement ( stream ); dlgSessionControl = new SessionControlDialog ( this, mngrSession ); updateMenu (); vectorRtpFrames = new Vector (); } } } protected void processRealizeComplete ( RealizeCompleteEvent event ) { String strMediaLocation; Dimension dimVideo; Dimension dimControlPanel; killCurrentView (); this.setCursor ( cursorNormal ); // Get the visual component panelVideo = new VideoPanel ( mediaPlayerCurrent ); panelVideo.setZoom ( dDefaultScale ); panelVideo.addMenuZoomActionListener ( this ); // Get the control component compControl = mediaPlayerCurrent.getControlPanelComponent (); // The bounds of the components will be set by LayoutManager, // but the components might start draw themselves in another thread // causing the garbage on the screen. // So we set here their bounds to avoid it. dimVideo = panelVideo.getPreferredSize (); // panelVideo.setBounds ( 0, 0, dimVideo.width, dimVideo.height ); if ( compControl != null ) { dimControlPanel = compControl.getPreferredSize (); compControl.setBounds ( 0, dimVideo.height, dimVideo.width, dimControlPanel.height ); } panelContent.add ( panelVideo, BorderLayout.CENTER ); // panelVideo.repaint (); if ( compControl != null) { panelContent.add ( compControl, BorderLayout.SOUTH ); compControl.repaint (); } // Plug-In Viewer - Implementation specific control controlPlugins = mediaPlayerCurrent.getControl ( "com.sun.media.JMD" ); controlGrabber = (FrameGrabbingControl) mediaPlayerCurrent.getControl ( "javax.media.control.FrameGrabbingControl" ); // Ask the player to prefetch data and prepare to start. mediaPlayerCurrent.prefetch (); strMediaLocation = mediaPlayerCurrent.getMediaLocation (); if ( strMediaLocation == null || strMediaLocation.trim().length() < 1 ) strMediaLocation = strOptionalTitle; setTitle ( strMediaLocation + " - " + APPNAME ); updateMenu (); } protected void processPrefetchComplete ( PrefetchCompleteEvent event ) { long lWait; if ( menuAutoPlay.getState() ) { if ( mediaPlayerCurrent != null && mediaPlayerCurrent.getTargetState() != Controller.Started ) { // Here, before we start the player, we should wait // until the visual component gets onto the screen, // so the user won't miss first few frames. // BUT how do we do it? mediaPlayerCurrent.start(); } } } protected void processFormatChange ( FormatChangeEvent event ) { killCurrentView (); // Get the visual component panelVideo = new VideoPanel ( mediaPlayerCurrent ); panelVideo.setZoom ( dDefaultScale ); panelVideo.addMenuZoomActionListener ( this ); panelContent.add ( panelVideo, BorderLayout.CENTER ); // Get the control component compControl = mediaPlayerCurrent.getControlPanelComponent (); if ( compControl != null) { panelContent.add ( compControl, BorderLayout.SOUTH ); } } private void openFile () { String nameFile = null; String nameUrl; MediaPlayer mediaPlayer; boolean boolResult; if ( dlgOpenFile == null ) dlgOpenFile = new FileDialog ( this, MENU_FILE_OPENFILE, FileDialog.LOAD ); if ( cfgJMApps != null ) nameFile = cfgJMApps.getLastOpenFile (); if ( nameFile != null ) dlgOpenFile.setFile ( nameFile ); dlgOpenFile.show (); nameFile = dlgOpenFile.getFile (); if ( nameFile == null ) return; nameFile = dlgOpenFile.getDirectory() + nameFile; if ( cfgJMApps != null ) cfgJMApps.setLastOpenFile ( nameFile ); nameUrl = "file:" + nameFile; open ( nameUrl ); } private void openUrl () { OpenUrlDialog dlgOpenUrl; String nameUrl = null; MediaPlayer mediaPlayer; boolean boolResult; String strAction; if ( cfgJMApps != null ) nameUrl = cfgJMApps.getLastOpenUrl (); dlgOpenUrl = new OpenUrlDialog ( this, nameUrl ); dlgOpenUrl.show (); strAction = dlgOpenUrl.getAction (); if ( !strAction.equals(JMDialog.ACTION_OPEN) ) return; nameUrl = dlgOpenUrl.getUrl (); if ( nameUrl == null ) return; if ( cfgJMApps != null ) cfgJMApps.setLastOpenUrl ( nameUrl ); open ( nameUrl ); } private void openRtp () { OpenRtpDialog dlgOpenRtp; String strAction;// SessionManager mngrSession;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -