📄 saveasdialog.java
字号:
JMAppsCfg.TrackData dataTrack; tabControl = new TabControl ( TabControl.ALIGN_TOP ); nIndexAudio = 0; nIndexVideo = 0; nCount = arrTrackControls.length; for ( i = 0; i < nCount; i++ ) { format = arrTrackControls[i].getFormat (); if ( format instanceof AudioFormat ) { nIndexAudio++; if ( nAudioTrackCount < 2 ) strTitle = new String ( strAudio ); else strTitle = new String ( strAudio + " " + nIndexAudio ); panelAudio = new TrackPanelAudio ( arrTrackControls[i], this ); tabControl.addPage ( panelAudio, strTitle, imageAudioEn ); hashtablePanelsAudio.put ( strTitle, panelAudio ); if ( cfgJMApps != null ) { dataTrack = cfgJMApps.getLastSaveFileTrackData ( strTitle ); if ( dataTrack != null ) panelAudio.setDefaults ( dataTrack.boolEnable, dataTrack.format ); } } else if ( format instanceof VideoFormat ) { nIndexVideo++; if ( nVideoTrackCount < 2 ) strTitle = new String ( strVideo ); else strTitle = new String ( strVideo + " " + nIndexVideo ); panelVideo = new TrackPanelVideo ( arrTrackControls[i], this ); tabControl.addPage ( panelVideo, strTitle, imageVideoEn ); hashtablePanelsVideo.put ( strTitle, panelVideo ); if ( cfgJMApps != null ) { dataTrack = cfgJMApps.getLastSaveFileTrackData ( strTitle ); if ( dataTrack != null ) panelVideo.setDefaults ( dataTrack.boolEnable, dataTrack.format ); } } } return ( tabControl ); } /** * This method is used by method init() to create the panel that contains * the choice of the media type for output. * @return created panel * @exception Exception */ private Panel createPanelGeneral () throws Exception { Panel panelGeneral; Panel panelFormat; Label label; String strValue; panelGeneral = new Panel ( new GridLayout(0,1,4,4) ); panelFormat = new Panel ( new BorderLayout() ); panelGeneral.add ( panelFormat ); label = new Label ( JMFI18N.getResource("jmstudio.saveas.format") ); panelFormat.add ( label, BorderLayout.WEST ); comboContentType = new Choice (); comboContentType.addItemListener ( this ); for ( int i = 0; i < supportedCDs.length; i++ ) { if (!(supportedCDs[i] instanceof FileTypeDescriptor)) continue; String ct = supportedCDs[i].getContentType(); strValue = transCDToDesc ( ct ); if ( nAudioTrackCount < 1 ) { if ( strValue.equals(STR_AIFF) || strValue.equals(STR_GSM) || strValue.equals(STR_WAVE) || strValue.equals(STR_BASIC_AUDIO) || strValue.equals(STR_MPEG_AUDIO) ) continue; } comboContentType.addItem ( strValue ); } strValue = null; if ( cfgJMApps != null ) strValue = cfgJMApps.getLastSaveFileContentType (); if ( strValue == null ) strValue = transCDToDesc ( ContentDescriptor.mimeTypeToPackageName(strContentType) ); comboContentType.select ( strValue ); panelFormat.add ( comboContentType, BorderLayout.CENTER ); return ( panelGeneral ); } private String transCDToDesc(String strContentType) { if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.MSVIDEO)) ) return ( STR_MSVIDEO ); else if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.QUICKTIME)) ) return ( STR_QUICKTIME ); else if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.AIFF)) ) return ( STR_AIFF ); else if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.GSM)) ) return ( STR_GSM ); else if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.WAVE)) ) return ( STR_WAVE ); else if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.BASIC_AUDIO)) ) return ( STR_BASIC_AUDIO ); else if ( strContentType.equals(ContentDescriptor.mimeTypeToPackageName(FileTypeDescriptor.MPEG_AUDIO)) ) return ( STR_MPEG_AUDIO ); else return strContentType; } /** * This method is called, when the user presses button "OK". It opens system * FileDialog. After the user chooses the target file it initiates the saving * process, puts the Progress dialog on the screen, and launches the thread * to monitor the progress and update the Progress dialog. */ private void doSave () { int i; MediaLocator mediaDest; DataSource dataSource; Object arrControls[]; MonitorControl monitorControl; boolean boolResult; String strFileContentType = null; AudioFormat formatAudio; FileDialog dlgFile; String strDirName = null; String strFileName = null; Enumeration enumKeys; String strPanel; TrackPanelVideo panelVideo; TrackPanelAudio panelAudio; int nMediaDuration; Component monitor = null; String strValue; TrackControl trackControl; JMAppsCfg.TrackData dataTrack; dlgFile = new FileDialog ( frameOwner, JMFI18N.getResource("jmstudio.saveas.filedialog"), FileDialog.SAVE ); i = inputURL.indexOf ( ':' ); if ( i > 2 ) strFileName = inputURL.substring ( i + 1 ); else strFileName = new String ( inputURL ); if ( strFileName.indexOf('/') == 0 && strFileName.indexOf(':') == 2 ) strFileName = strFileName.substring ( 1 ); i = strFileName.lastIndexOf ( '.' ); if ( i >= 0 && strContentTypeExt != null ) strFileName = strFileName.substring ( 0, i + 1 ) + strContentTypeExt; else if ( i < 0 && strContentTypeExt != null ) strFileName = "Unknown." + strContentTypeExt; strDirName = cfgJMApps.getLastSaveFileDir (); i = Math.max ( strFileName.lastIndexOf('/'), strFileName.lastIndexOf('\\') ); if ( i > -1 ) { if ( strDirName == null ) strDirName = strFileName.substring ( 0, i ); strFileName = strFileName.substring ( i + 1 ); } if ( strDirName != null ) dlgFile.setDirectory ( strDirName ); dlgFile.setFile ( strFileName ); dlgFile.setVisible ( true ); strFileName = dlgFile.getFile (); if ( strFileName == null || strFileName.length() == 0 ) { // user pressed cancel on FileDialog return; } strDirName = dlgFile.getDirectory (); if ( strDirName != null ) { strFileName = strDirName.trim() + strFileName.trim(); cfgJMApps.setLastSaveFileDir ( strDirName ); } else strFileName = strFileName.trim(); // looks like here is a good place to save default values for the next run if ( cfgJMApps != null ) { strValue = comboContentType.getSelectedItem (); cfgJMApps.setLastSaveFileContentType ( strValue ); } setCursor ( new Cursor(Cursor.WAIT_CURSOR) ); try { // configure processor// System.err.println("Output content type = " + strContentType); processor.setContentDescriptor( new FileTypeDescriptor(strContentType) ); // go through parameters ... enumKeys = hashtablePanelsVideo.keys (); while ( enumKeys.hasMoreElements() ) { strPanel = (String) enumKeys.nextElement (); panelVideo = (TrackPanelVideo) hashtablePanelsVideo.get ( strPanel ); panelVideo.updateTrack (); if ( cfgJMApps != null ) { dataTrack = cfgJMApps.createTrackDataObject(); trackControl = panelVideo.getTrackControl (); dataTrack.boolEnable = trackControl.isEnabled (); dataTrack.format = trackControl.getFormat (); cfgJMApps.setLastSaveFileTrackData ( dataTrack, strPanel ); } } enumKeys = hashtablePanelsAudio.keys (); while ( enumKeys.hasMoreElements() ) { strPanel = (String) enumKeys.nextElement (); panelAudio = (TrackPanelAudio) hashtablePanelsAudio.get ( strPanel ); panelAudio.updateTrack (); if ( cfgJMApps != null ) { dataTrack = cfgJMApps.createTrackDataObject(); trackControl = panelAudio.getTrackControl (); dataTrack.boolEnable = trackControl.isEnabled (); dataTrack.format = trackControl.getFormat (); cfgJMApps.setLastSaveFileTrackData ( dataTrack, strPanel ); } } boolResult = waitForState ( processor, Processor.Realized ); if ( boolResult == false ) {// MessageDialog.createErrorDialogModeless ( frameOwner,// JMFI18N.getResource("jmstudio.error.processor.realize")// + " " + strFailMessage ); setCursor ( Cursor.getDefaultCursor() ); processor.close (); this.dispose (); return; }/* Control swc = processor.getControl("javax.media.control.StreamWriterControl"); if (swc != null) { ((StreamWriterControl)swc).setStreamSizeLimit(1000000); }*/// if ( strContentType == null ) strFileContentType = "file:";// else// strFileContentType = "file." + strContentType + ":"; dataSource = processor.getDataOutput (); mediaDest = new MediaLocator ( strFileContentType + strFileName ); dataSink = Manager.createDataSink ( dataSource, mediaDest ); boolSaving = true; monitorControl = (MonitorControl) processor.getControl("javax.media.control.MonitorControl"); if (monitorControl != null) monitor = monitorControl.getControlComponent(); Time duration = processor.getDuration(); nMediaDuration = (int)duration.getSeconds(); dataSink.addDataSinkListener(this); dataSink.open ();// if (captureFormat != null)// new PlayerWindow(processor, "Transcoding Processor", true, false);// else dataSink.start (); processor.start ();// dataSource.start (); if ( nMediaDuration > 0 && duration != Duration.DURATION_UNBOUNDED && duration != Duration.DURATION_UNKNOWN ) { dlgProgress = new ProgressDialog ( frameOwner, JMFI18N.getResource("jmstudio.saveprogress.title"), 0, nMediaDuration, this ); } else { dlgProgress = new ProgressDialog ( frameOwner, JMFI18N.getResource("jmstudio.saveprogress.title"), JMFI18N.getResource("jmstudio.saveprogress.label"),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -