Changeset 114

Show
Ignore:
Timestamp:
12/12/06 18:31:29 (2 years ago)
Author:
jlee
Message:

Add setters for settings, OK and Cancel instead of just Close in all dialogs, and MPlayer location configuration in preparation for installer-less jar

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/org/thestaticvoid/iriverter/AudioSyncDialog.java

    r32 r114  
    1212        private Label bringAudioLabel, millisecondsLabel, videoLabel; 
    1313        private Spinner delayInput; 
    14         private Button autoSync, before, after, dismiss
     14        private Button autoSync, before, after, cancel, ok
    1515         
    16         public static final int AUTO_SYNC = Integer.MAX_VALUE; 
    17          
    18         public AudioSyncDialog(Shell parent, int style, int delay) { 
     16        public AudioSyncDialog(Shell parent, int style) { 
    1917                super(parent, style); 
    20                 this.delay = delay
     18                delay = ConverterOptions.getAudioDelay()
    2119        } 
    2220         
    23         public int open() { 
     21        public void open() { 
    2422                shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    2523                shell.setText("Audio Sync"); 
     
    4341                autoSync = new Button(shell, SWT.CHECK); 
    4442                autoSync.setText("Automatically Sync"); 
    45                 autoSync.setSelection(delay == AUTO_SYNC); 
     43                autoSync.setSelection(ConverterOptions.getAutoSync()); 
    4644                gridData = new GridData(); 
    4745                gridData.horizontalSpan = 5; 
     
    7472                videoLabel.setText("video"); 
    7573                 
    76                 dismiss = new Button(shell, SWT.PUSH); 
    77                 dismiss.setText("Close"); 
     74                Composite dismissComposite = new Composite(shell, SWT.NONE); 
     75                dismissComposite.setLayout(new RowLayout()); 
    7876                gridData = new GridData(); 
    79                 gridData.widthHint = 75; 
    8077                gridData.horizontalSpan = 5; 
    8178                gridData.horizontalAlignment = SWT.RIGHT; 
    82                 dismiss.setLayoutData(gridData); 
    83                 dismiss.addSelectionListener(this); 
     79                dismissComposite.setLayoutData(gridData); 
     80                 
     81                cancel = new Button(dismissComposite, SWT.PUSH); 
     82                cancel.setText("Cancel"); 
     83                RowData rowData = new RowData(); 
     84                rowData.width = 75; 
     85                cancel.setLayoutData(rowData); 
     86                cancel.addSelectionListener(this); 
     87                 
     88                ok = new Button(dismissComposite, SWT.PUSH); 
     89                ok.setText("OK"); 
     90                rowData = new RowData(); 
     91                rowData.width = 75; 
     92                ok.setLayoutData(rowData); 
     93                ok.addSelectionListener(this); 
    8494                 
    8595                if (autoSync.getSelection()) { 
     
    94104                while (!shell.isDisposed()) 
    95105                        if (!getParent().getDisplay().readAndDispatch()) 
    96                                 getParent().getDisplay().sleep();        
    97                  
    98                 return delay; 
     106                                getParent().getDisplay().sleep(); 
    99107        } 
    100108         
     
    103111        } 
    104112         
    105         public void widgetSelected(SelectionEvent e) {           
    106                 if (e.getSource() == dismiss) { 
    107                         try { 
    108                                 if (autoSync.getSelection()) { 
    109                                         delay = AUTO_SYNC; 
    110                                         shell.dispose(); 
    111                                 } 
    112                                  
     113        public void widgetSelected(SelectionEvent e) { 
     114                if (e.getSource() == autoSync) 
     115                        toggleSelection(); 
     116                 
     117                if (e.getSource() == cancel) 
     118                        shell.dispose(); 
     119                 
     120                if (e.getSource() == ok) { 
     121                        if (autoSync.getSelection()) { 
     122                                ConverterOptions.setAutoSync(true); 
     123                                ConverterOptions.setAudioDelay(0); 
     124                        } else { 
    113125                                delay = delayInput.getSelection(); 
    114                                  
    115126                                if (before.getSelection()) 
    116127                                        delay = -delay; 
    117                         } catch (Exception exception) { 
    118                                 return; 
     128                                 
     129                                ConverterOptions.setAutoSync(false); 
     130                                ConverterOptions.setAudioDelay(delay); 
    119131                        } 
    120132                         
    121133                        shell.dispose(); 
    122134                } 
    123                  
    124                 if (e.getSource() == autoSync) 
    125                         toggleSelection(); 
    126135        } 
    127136         
  • trunk/src/org/thestaticvoid/iriverter/AutomaticallySplitDialog.java

    r32 r114  
    99public class AutomaticallySplitDialog extends Dialog implements SelectionListener { 
    1010        private Shell shell; 
    11         private boolean autoSplit; 
    12         private int splitTime; 
    1311        private Label splitVideoEveryLabel, minutesLabel; 
    1412        private Spinner splitTimeInput; 
    15         private Button automaticallySplit, dismiss
     13        private Button automaticallySplit, cancel, ok
    1614         
    17         public static final int NO_SPLIT = Integer.MAX_VALUE; 
    18          
    19         public AutomaticallySplitDialog(Shell parent, int style, boolean autoSplit, int delay) { 
     15        public AutomaticallySplitDialog(Shell parent, int style) { 
    2016                super(parent, style); 
    21                 this.autoSplit = autoSplit; 
    22                 this.splitTime = delay; 
    2317        } 
    2418         
    25         public int open() { 
     19        public void open() { 
    2620                shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    2721                shell.setText("Automatically Split"); 
     
    4539                automaticallySplit = new Button(shell, SWT.CHECK); 
    4640                automaticallySplit.setText("Automatically Split"); 
    47                 automaticallySplit.setSelection(autoSplit); 
     41                automaticallySplit.setSelection(ConverterOptions.getAutoSplit()); 
    4842                gridData = new GridData(); 
    4943                gridData.horizontalSpan = 3; 
     
    5549                 
    5650                splitTimeInput = new Spinner(shell, SWT.BORDER); 
    57                 splitTimeInput.setSelection(Math.abs(splitTime)); 
     51                splitTimeInput.setSelection(Math.abs(ConverterOptions.getSplitTime())); 
    5852                splitTimeInput.setMinimum(0); 
    5953                 
     
    6155                minutesLabel.setText("minutes"); 
    6256                 
    63                 dismiss = new Button(shell, SWT.PUSH); 
    64                 dismiss.setText("Close"); 
     57                Composite dismissComposite = new Composite(shell, SWT.NONE); 
     58                dismissComposite.setLayout(new RowLayout()); 
    6559                gridData = new GridData(); 
    66                 gridData.widthHint = 75; 
    6760                gridData.horizontalSpan = 3; 
    6861                gridData.horizontalAlignment = SWT.RIGHT; 
    69                 dismiss.setLayoutData(gridData); 
    70                 dismiss.addSelectionListener(this); 
     62                dismissComposite.setLayoutData(gridData); 
     63                 
     64                cancel = new Button(dismissComposite, SWT.PUSH); 
     65                cancel.setText("Cancel"); 
     66                RowData rowData = new RowData(); 
     67                rowData.width = 75; 
     68                cancel.setLayoutData(rowData); 
     69                cancel.addSelectionListener(this); 
     70                 
     71                ok = new Button(dismissComposite, SWT.PUSH); 
     72                ok.setText("OK"); 
     73                rowData = new RowData(); 
     74                rowData.width = 75; 
     75                ok.setLayoutData(rowData); 
     76                ok.addSelectionListener(this); 
    7177                 
    7278                if (!automaticallySplit.getSelection()) 
     
    7783                while (!shell.isDisposed()) 
    7884                        if (!getParent().getDisplay().readAndDispatch()) 
    79                                 getParent().getDisplay().sleep();        
    80                  
    81                 return splitTime; 
     85                                getParent().getDisplay().sleep(); 
    8286        } 
    8387         
     
    8690        } 
    8791         
    88         public void widgetSelected(SelectionEvent e) {           
    89                 if (e.getSource() == dismiss) { 
    90                         if (!automaticallySplit.getSelection()) 
    91                                 splitTime = NO_SPLIT; 
    92                         else 
    93                                 splitTime = splitTimeInput.getSelection(); 
    94                          
     92        public void widgetSelected(SelectionEvent e) { 
     93                if (e.getSource() == automaticallySplit) 
     94                        toggleSelection(); 
     95                 
     96                if (e.getSource() == cancel) 
     97                        shell.dispose(); 
     98                 
     99                if (e.getSource() == ok) {                       
     100                        ConverterOptions.setAutoSplit(automaticallySplit.getSelection()); 
     101                        ConverterOptions.setSplitTime(splitTimeInput.getSelection()); 
    95102                        shell.dispose(); 
    96103                } 
    97                  
    98                 if (e.getSource() == automaticallySplit) 
    99                         toggleSelection(); 
    100104        } 
    101105         
  • trunk/src/org/thestaticvoid/iriverter/BitrateDialog.java

    r83 r114  
    99public class BitrateDialog extends Dialog implements SelectionListener { 
    1010        private Shell shell; 
    11         private Bitrate maxBitrate, currentBitrate; 
    1211        private int currentVideoBitrate, currentAudioBitrate; 
    1312        private Scale videoBitrateScale, audioBitrateScale; 
    1413        private Label currentVideoBitrateLabel, currentAudioBitrateLabel; 
    15         private Button dismiss
     14        private Button cancel, ok
    1615         
    17         public BitrateDialog(Shell parent, int style, Bitrate maxBitrate, Bitrate currentBitrate) { 
     16        public BitrateDialog(Shell parent, int style) { 
    1817                super(parent, style); 
    19                 this.maxBitrate = maxBitrate; 
    20                 this.currentBitrate = currentBitrate; 
    21                 currentVideoBitrate = currentBitrate.getVideo(); 
    22                 currentAudioBitrate = currentBitrate.getAudio(); 
     18                currentVideoBitrate = ConverterOptions.getVideoBitrate(); 
     19                currentAudioBitrate = ConverterOptions.getAudioBitrate(); 
    2320        } 
    2421         
    25         public Bitrate open() { 
     22        public void open() { 
    2623                shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    2724                shell.setText("Bitrate"); 
     
    4845                videoBitrateScale = new Scale(shell, SWT.HORIZONTAL); 
    4946                videoBitrateScale.setMinimum(50); 
    50                 videoBitrateScale.setMaximum(maxBitrate.getVideo() / 2); 
     47                videoBitrateScale.setMaximum(ConverterOptions.getCurrentProfile().getMaxVideoBitrate() / 2); 
    5148                videoBitrateScale.setSelection(currentVideoBitrate / 2); 
    5249                videoBitrateScale.setPageIncrement(25); 
     
    6259                audioBitrateScale = new Scale(shell, SWT.HORIZONTAL); 
    6360                audioBitrateScale.setMinimum(2); 
    64                 audioBitrateScale.setMaximum(maxBitrate.getAudio() / 16); 
     61                audioBitrateScale.setMaximum(ConverterOptions.getCurrentProfile().getMaxAudioBitrate() / 16); 
    6562                audioBitrateScale.setSelection(currentAudioBitrate / 16); 
    6663                audioBitrateScale.setPageIncrement(1); 
     
    7168                currentAudioBitrateLabel.setText(currentAudioBitrate + " Kbps"); 
    7269                 
    73                 dismiss = new Button(shell, SWT.PUSH); 
    74                 dismiss.setText("Close"); 
     70                Composite dismissComposite = new Composite(shell, SWT.NONE); 
     71                dismissComposite.setLayout(new RowLayout()); 
    7572                gridData = new GridData(); 
    76                 gridData.widthHint = 75; 
    7773                gridData.horizontalSpan = 3; 
    7874                gridData.horizontalAlignment = SWT.RIGHT; 
    79                 dismiss.setLayoutData(gridData); 
    80                 dismiss.addSelectionListener(this); 
     75                dismissComposite.setLayoutData(gridData); 
     76                 
     77                cancel = new Button(dismissComposite, SWT.PUSH); 
     78                cancel.setText("Cancel"); 
     79                RowData rowData = new RowData(); 
     80                rowData.width = 75; 
     81                cancel.setLayoutData(rowData); 
     82                cancel.addSelectionListener(this); 
     83                 
     84                ok = new Button(dismissComposite, SWT.PUSH); 
     85                ok.setText("OK"); 
     86                rowData = new RowData(); 
     87                rowData.width = 75; 
     88                ok.setLayoutData(rowData); 
     89                ok.addSelectionListener(this); 
    8190                 
    8291                shell.pack(); 
     
    8695                while (!shell.isDisposed()) 
    8796                        if (!getParent().getDisplay().readAndDispatch()) 
    88                                 getParent().getDisplay().sleep();        
    89                  
    90                 return new Bitrate(currentVideoBitrate, currentAudioBitrate); 
     97                                getParent().getDisplay().sleep(); 
    9198        } 
    9299         
     
    108115                } 
    109116                 
    110                 if (e.getSource() == dismiss
     117                if (e.getSource() == cancel
    111118                        shell.dispose(); 
     119                 
     120                if (e.getSource() == ok) { 
     121                        ConverterOptions.setVideoBitrate(currentVideoBitrate); 
     122                        ConverterOptions.setAudioBitrate(currentAudioBitrate); 
     123                        shell.dispose(); 
     124                } 
    112125        } 
    113126} 
  • trunk/src/org/thestaticvoid/iriverter/Converter.java

    r107 r114  
    77        private List jobs, notSplitVideos; 
    88        private ProgressDialogInfo progressDialogInfo; 
     9        private String mplayerPath; 
    910        private Process proc; 
    1011        private boolean isCanceled; 
    1112        private int exitCode; 
    1213         
    13         public Converter(List jobs, ProgressDialogInfo progressDialogInfo) { 
     14        public Converter(List jobs, ProgressDialogInfo progressDialogInfo, String mplayerPath) { 
    1415                this.jobs = Converter.checkForOverwritingFiles(Converter.expandSingleJobsToMultiple(Converter.removeInvalidJobs(jobs))); 
    1516                this.progressDialogInfo = progressDialogInfo; 
     17                this.mplayerPath = mplayerPath; 
    1618                isCanceled = false; 
    1719                 
     
    175177                List commandList = new ArrayList(); 
    176178                 
    177                 commandList.add(MPlayerInfo.getMPlayerPath() + "mencoder"); 
     179                commandList.add(mplayerPath + "mencoder"); 
    178180                 
    179181                commandList.add(inputVideo); 
     
    233235                commandList.add("harddup"); 
    234236                 
    235                 if (ConverterOptions.getVolumeFilter() == VolumeFilter.VOLNORM) { 
     237                if (ConverterOptions.getVolumeFilter().equals("volnorm")) { 
    236238                        commandList.add("-af"); 
    237239                        commandList.add("volnorm"); 
    238                 } else if (ConverterOptions.getVolumeFilter() == VolumeFilter.VOLUME) { 
     240                } else if (ConverterOptions.getVolumeFilter().equals("volume")) { 
    239241                        commandList.add("-af"); 
    240242                        commandList.add("volume=" + ConverterOptions.getGain()); 
     
    261263                progressDialogInfo.setStatus("Gathering information about the input video..."); 
    262264                 
    263                 MPlayerInfo info = new MPlayerInfo(singleVideoInfo.getInputVideo()); 
     265                MPlayerInfo info = new MPlayerInfo(singleVideoInfo.getInputVideo(), mplayerPath); 
    264266                if (!info.videoSupported()) { 
    265267                        Logger.logMessage("Unsupported video", Logger.ERROR); 
     
    340342                 
    341343                if (manualSplitInfo.getMarks()[0].getTime() == Mark.START_MARK) 
    342                         runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", manualSplitInfo.getVideo(), "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-endpos", "" + manualSplitInfo.getMarks()[1].getTime()}); 
     344                        runConversionCommand(new String[]{mplayerPath + "mencoder", manualSplitInfo.getVideo(), "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-endpos", "" + manualSplitInfo.getMarks()[1].getTime()}); 
    343345                else if (manualSplitInfo.getMarks()[1].getTime() == Mark.END_MARK) 
    344                         runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", manualSplitInfo.getVideo(), "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + manualSplitInfo.getMarks()[0].getTime()}); 
     346                        runConversionCommand(new String[]{mplayerPath + "mencoder", manualSplitInfo.getVideo(), "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + manualSplitInfo.getMarks()[0].getTime()}); 
    345347                else 
    346                         runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", manualSplitInfo.getVideo(), "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + manualSplitInfo.getMarks()[0].getTime(), "-endpos", "" + (manualSplitInfo.getMarks()[1].getTime() - manualSplitInfo.getMarks()[0].getTime())}); 
     348                        runConversionCommand(new String[]{mplayerPath + "mencoder", manualSplitInfo.getVideo(), "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + manualSplitInfo.getMarks()[0].getTime(), "-endpos", "" + (manualSplitInfo.getMarks()[1].getTime() - manualSplitInfo.getMarks()[0].getTime())}); 
    347349        } 
    348350         
     
    390392                                progressDialogInfo.setOutputVideo(new File(joinVideosInfo.getOutputVideo()).getName()); 
    391393                                progressDialogInfo.setStatus("Writing header"); 
    392                                 splitVideo(joinVideosInfo.getOutputVideo(), runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", "-forceidx", tempFile.toString(), "-o", joinVideosInfo.getOutputVideo(), "-ovc", "copy", "-oac", "copy"})); 
     394                                splitVideo(joinVideosInfo.getOutputVideo(), runConversionCommand(new String[]{mplayerPath + "mencoder", "-forceidx", tempFile.toString(), "-o", joinVideosInfo.getOutputVideo(), "-ovc", "copy", "-oac", "copy"})); 
    393395                        } 
    394396                } catch (IOException e) { 
     
    444446                         
    445447                        if ((i + 1) == 1) 
    446                                 runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", inputVideo, "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-endpos", "" + (length / pieces)}); 
     448                                runConversionCommand(new String[]{mplayerPath + "mencoder", inputVideo, "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-endpos", "" + (length / pieces)}); 
    447449                        else if ((i + 1) == pieces) 
    448                                 runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", inputVideo, "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + (length / pieces) * i}); 
     450                                runConversionCommand(new String[]{mplayerPath + "mencoder", inputVideo, "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + (length / pieces) * i}); 
    449451                        else 
    450                                 runConversionCommand(new String[]{MPlayerInfo.getMPlayerPath() + "mencoder", inputVideo, "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + (length / pieces) * i, "-endpos", "" + (length / pieces)}); 
     452                                runConversionCommand(new String[]{mplayerPath + "mencoder", inputVideo, "-o", outputVideo, "-ovc", "copy", "-oac", "copy", "-ss", "" + (length / pieces) * i, "-endpos", "" + (length / pieces)}); 
    451453                } 
    452454        } 
  • trunk/src/org/thestaticvoid/iriverter/ConverterOptions.java

    r102 r114  
    2828        } 
    2929 
    30         public static void writeOption(String option, String setting) { 
     30        private static void writeOption(String option, String setting) { 
    3131                try { 
    3232                        Logger.logMessage("Setting: " + option + "=" + setting, Logger.INFO); 
     
    6262        } 
    6363 
    64         public static String readOption(String option) { 
     64        private static String readOption(String option) { 
    6565                String returnSetting = ""; 
    6666 
     
    107107        } 
    108108         
     109        public static void setPanAndScan(boolean panAndScan) { 
     110                writeOption("panAndScan", "" + panAndScan); 
     111        } 
     112         
    109113        public static int getVideoBitrate() { 
    110114                String videoBitrate = readOption("videoBitrate"); 
     
    115119        } 
    116120         
     121        public static void setVideoBitrate(int videoBitrate) { 
     122                writeOption("videoBitrate", "" + videoBitrate); 
     123        } 
     124         
    117125        public static int getAudioBitrate() { 
    118126                String audioBitrate = readOption("audioBitrate"); 
     
    122130                return Integer.parseInt(audioBitrate); 
    123131        } 
     132         
     133        public static void setAudioBitrate(int audioBitrate) { 
     134                writeOption("audioBitrate", "" + audioBitrate); 
     135        } 
    124136 
    125137        public static Dimensions getDimensions() { 
     
    131143        } 
    132144         
     145        public static void setDimensions(Dimensions dimensions) { 
     146                writeOption("dimensions", "" + dimensions); 
     147        } 
     148         
    133149        public static boolean getAutoSync() { 
    134150                String autoSync = readOption("autoSync"); 
     
    139155        } 
    140156         
     157        public static void setAutoSync(boolean autoSync) { 
     158                writeOption("autoSync", "" + autoSync); 
     159        } 
     160         
    141161        public static int getAudioDelay() { 
    142162                String audioDelay = readOption("audioDelay"); 
     
    147167        } 
    148168         
     169        public static void setAudioDelay(int audioDelay) { 
     170                writeOption("audioDelay", "" + audioDelay); 
     171        } 
     172         
    149173        public static boolean getAutoSplit() { 
    150174                String autoSplit = readOption("autoSplit"); 
     
    155179        } 
    156180         
     181        public static void setAutoSplit(boolean autoSplit) { 
     182                writeOption("autoSplit", "" + autoSplit); 
     183        } 
     184         
    157185        public static int getSplitTime() { 
    158186                String splitTime = readOption("splitTime"); 
     
    163191        } 
    164192         
    165         public static int getVolumeFilter() { 
     193        public static void setSplitTime(int splitTime) { 
     194                writeOption("splitTime", "" + splitTime); 
     195        } 
     196         
     197        public static String getVolumeFilter() { 
    166198                String volumeFilter = readOption("volumeFilter"); 
    167                 if (volumeFilter.equals("") || volumeFilter.equals("none")) 
    168                         return VolumeFilter.NONE; 
    169                 else if (volumeFilter.equals("volnorm")) 
    170                         return VolumeFilter.VOLNORM; 
    171                  
    172                 return VolumeFilter.VOLUME;                      
     199                if (volumeFilter.equals("")) 
     200                        return "none"; 
     201                 
     202                return volumeFilter;                     
     203        } 
     204         
     205        public static void setVolumeFilter(String volumeFilter) { 
     206                writeOption("volumeFilter", volumeFilter); 
    173207        } 
    174208         
     
    180214                return Double.parseDouble(gain); 
    181215        } 
     216         
     217        public static void setGain(double gain) { 
     218                writeOption("gain", "" + gain); 
     219        } 
     220         
     221        public static String getMPlayerSource() { 
     222                String mplayerSource = readOption("mplayerSource"); 
     223                if (mplayerSource.equals("")) 
     224                        if (System.getProperty("os.name").indexOf("Windows") >= 0) 
     225                                return "download"; 
     226                        else 
     227                                return "local"; 
     228                 
     229                return mplayerSource; 
     230        } 
     231         
     232        public static void setMPlayerSource(String mplayerSource) { 
     233                writeOption("mplayerSource", mplayerSource); 
     234        } 
     235         
     236        public static boolean getDownloadExtraCodecs() { 
     237                String downloadExtraCodecs = readOption("downloadExtraCodecs"); 
     238                if (downloadExtraCodecs.equals("")) 
     239                        return false; 
     240                 
     241                return downloadExtraCodecs.equals("true"); 
     242        } 
     243         
     244        public static void setDownloadExtraCodecs(boolean downloadExtraCodecs) { 
     245                writeOption("downloadExtraCodecs", "" + downloadExtraCodecs); 
     246        } 
     247         
     248        public static String getMPlayerPath() { 
     249                String mplayerPath = readOption("mplayerPath"); 
     250                if (mplayerPath.equals("") || !new File(mplayerPath).isDirectory()) 
     251                        return "."; 
     252                 
     253                return mplayerPath; 
     254        } 
     255         
     256        public static void setMPlayerPath(String mplayerPath) { 
     257                writeOption("mplayerPath", mplayerPath); 
     258        } 
    182259} 
  • trunk/src/org/thestaticvoid/iriverter/ConverterUI.java

    r102 r114  
    1818        private CTabFolder tabFolder; 
    1919        private Map profileMenuItems, dimensionsMenuItems; 
    20         private MenuItem convert, playFile, newSingleVideo, newDirectory, newDVD, advancedJobs, manualSplit, joinVideos, moveUp, moveDown, closeJob, closeAllJobs, quit, bitrate, videoSize, panAndScan, advancedOptions, audioSync, automaticallySplit, volume, contents, logViewer, about; 
     20        private MenuItem convert, playFile, newSingleVideo, newDirectory, newDVD, advancedJobs, manualSplit, joinVideos, moveUp, moveDown, closeJob, closeAllJobs, quit, bitrate, videoSize, panAndScan, advancedOptions, audioSync, automaticallySplit, volume, mplayerPath, contents, logViewer, about; 
    2121        private Menu videoSizeMenu; 
    2222        private DropTarget target; 
     
    250250                volume.setText("&Volume..."); 
    251251                volume.addSelectionListener(this); 
     252                 
     253                mplayerPath = new MenuItem(advancedOptionsMenu, SWT.PUSH); 
     254                mplayerPath.setText("&MPlayer Path..."); 
     255                mplayerPath.addSelectionListener(this); 
    252256 
    253257                MenuItem help = new MenuItem(menu, SWT.CASCADE); 
     
    321325                         
    322326                        progressDialog = new ProgressDialog(shell, SWT.NONE); 
    323                         Converter converter = new Converter(jobs, progressDialog); 
    324                         converter.start(); 
    325                         progressDialog.open(); 
    326                         converter.cancel(); 
     327                         
     328                        boolean canceled = false; 
     329                        while (!canceled) 
     330                                try { 
     331                                        Converter converter = new Converter(jobs, progressDialog, MPlayerInfo.getMPlayerPath()); 
     332                                        converter.start(); 
     333                                        progressDialog.open(); 
     334                                        converter.cancel(); 
     335                                } catch (MPlayerNotFoundException mpe) { 
     336                                        canceled = new MPlayerPathDialog(shell, SWT.NONE).open(); 
     337                                } 
    327338                } 
    328339                 
     
    339350                                } catch (IOException io) { 
    340351                                        io.printStackTrace(); 
     352                                } catch (MPlayerNotFoundException mpe) { 
     353                                        MPlayerPathDialog dialog = new MPlayerPathDialog(shell, SWT.NONE); 
     354                                        dialog.open(); 
    341355                                } 
    342356                        } 
     
    423437                } 
    424438                 
    425                 if (e.getSource() == bitrate) { 
    426                         BitrateDialog bitrateDialog = new BitrateDialog(shell, SWT.NONE, new Bitrate(ConverterOptions.getCurrentProfile().getMaxVideoBitrate(), ConverterOptions.getCurrentProfile().getMaxAudioBitrate()), new Bitrate(ConverterOptions.getVideoBitrate(), ConverterOptions.getAudioBitrate())); 
    427                         Bitrate newBitrate = bitrateDialog.open(); 
    428                         ConverterOptions.writeOption("videoBitrate", "" + newBitrate.getVideo()); 
    429                         ConverterOptions.writeOption("audioBitrate", "" + newBitrate.getAudio()); 
    430                 } 
     439                if (e.getSource() == bitrate) 
     440                        new BitrateDialog(shell, SWT.NONE).open(); 
    431441 
    432442                if (dimensionsMenuItems.containsKey(e.getSource())) { 
     
    435445                 
    436446                if (e.getSource() == panAndScan) 
    437                         ConverterOptions.writeOption("panAndScan", "" + panAndScan.getSelection()); 
    438                  
    439                 if (e.getSource() == audioSync) { 
    440                         int audioDelay = new AudioSyncDialog(shell, SWT.NONE, (ConverterOptions.getAutoSync()) ? AudioSyncDialog.AUTO_SYNC : ConverterOptions.getAudioDelay()).open(); 
    441                          
    442                         if (audioDelay == AudioSyncDialog.AUTO_SYNC) { 
    443                                 ConverterOptions.writeOption("autoSync", "true"); 
    444                                 ConverterOptions.writeOption("audioDelay", "0"); 
    445                         } else { 
    446                                 ConverterOptions.writeOption("autoSync", "false"); 
    447                                 ConverterOptions.writeOption("audioDelay", "" + audioDelay); 
    448                         } 
    449                 } 
    450                  
    451                 if (e.getSource() == automaticallySplit) { 
    452                         int splitTime = new AutomaticallySplitDialog(shell, SWT.NONE, ConverterOptions.getAutoSplit(), ConverterOptions.getSplitTime()).open(); 
    453                          
    454                         if (splitTime == AutomaticallySplitDialog.NO_SPLIT) 
    455                                 ConverterOptions.writeOption("autoSplit", "false"); 
    456                         else { 
    457                                 ConverterOptions.writeOption("autoSplit", "true"); 
    458                                 ConverterOptions.writeOption("splitTime", "" + splitTime); 
    459                         } 
    460                 } 
    461                  
    462                 if (e.getSource() == volume) { 
    463                         double volume = new VolumeDialog(shell, SWT.NONE, ConverterOptions.getVolumeFilter(), ConverterOptions.getGain()).open(); 
    464                          
    465                         if (volume == VolumeDialog.NONE) 
    466                                 ConverterOptions.writeOption("volumeFilter", "none"); 
    467                         else if (volume == VolumeDialog.VOLNORM) 
    468                                 ConverterOptions.writeOption("volumeFilter", "volnorm"); 
    469                         else { 
    470                                 ConverterOptions.writeOption("volumeFilter", "volume"); 
    471                                 ConverterOptions.writeOption("gain", "" + volume); 
    472                         } 
     447                        ConverterOptions.setPanAndScan(panAndScan.getSelection()); 
     448                 
     449                if (e.getSource() == audioSync) 
     450                        new AudioSyncDialog(shell, SWT.NONE).open(); 
     451                 
     452                if (e.getSource() == automaticallySplit) 
     453                        new AutomaticallySplitDialog(shell, SWT.NONE).open(); 
     454 
     455                 
     456                if (e.getSource() == volume) 
     457                        new VolumeDialog(shell, SWT.NONE).open(); 
     458                 
     459                if (e.getSource() == mplayerPath) { 
     460                        new MPlayerPathDialog(shell, SWT.NONE).open(); 
    473461                } 
    474462                 
  • trunk/src/org/thestaticvoid/iriverter/DVD.java

    r102 r114  
    195195                if (e.getSource() == previewButton) { 
    196196                        if (!getDrive().equals("")) { 
    197                                 try { 
    198                                         java.util.List commandList = new ArrayList(); 
    199                                         commandList.add(MPlayerInfo.getMPlayerPath() + "mplayer"); 
    200                                         commandList.add("-dvd-device"); 
    201                                         commandList.add(getDrive()); 
    202                                         commandList.add("dvd://" + getTitle()); 
    203                                          
    204                                         if (getAudioStream() > -1) { 
    205                                                 commandList.add("-aid"); 
    206                                                 commandList.add("" + getAudioStream()); 
     197                                boolean canceled = false; 
     198                                while (!canceled) 
     199                                        try { 
     200                                                java.util.List commandList = new ArrayList(); 
     201                                                commandList.add(MPlayerInfo.getMPlayerPath() + "mplayer"); 
     202                                                commandList.add("-dvd-device"); 
     203                                                commandList.add(getDrive()); 
     204                                                commandList.add("dvd://" + getTitle()); 
     205                                                 
     206                                                if (getAudioStream() > -1) { 
     207                                                        commandList.add("-aid"); 
     208                                                        commandList.add("" + getAudioStream()); 
     209                                                } 
     210                                                 
     211                                                if (getSubtitles() > -1) { 
     212                                                        commandList.add("-sid"); 
     213                                                        commandList.add("" + getSubtitles()); 
     214                                                } 
     215                                                 
     216                                                String commandStr = ""; 
     217                                                String[] command = new String[commandList.size()]; 
     218                                                for (int i = 0; i < command.length; i++) { 
     219                                                        command[i] = (String) commandList.get(i); 
     220                                                        commandStr += command[i] + " "; 
     221                                                } 
     222                                                Logger.logMessage(commandStr, Logger.INFO); 
     223                                                 
     224                                                proc = Runtime.getRuntime().exec(command); 
     225                                        } catch (IOException io) { 
     226                                                io.printStackTrace(); 
     227                                                canceled = true; 
     228                                        } catch (MPlayerNotFoundException mpe) { 
     229                                                canceled = new MPlayerPathDialog(getParent().getShell(), SWT.NONE).open(); 
    207230                                        }