Changeset 146

Show
Ignore:
Timestamp:
02/16/07 18:26:07 (2 years ago)
Author:
jlee
Message:

Distribute MPlayer for Windows via Java Web Start

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build.xml

    r141 r146  
    22<project name="iriverter" default="jar" basedir="."> 
    33        <property name="package" value="org/thestaticvoid/iriverter" /> 
     4        <property name="mplayer.package" value="hu/mplayerhq" /> 
    45        <property name="main.class" value="${package}/ConverterUI" /> 
    56        <property name="src.dir" value="src" /> 
     
    6566                        <fileset dir="${src.dir}/${icons.dir}" /> 
    6667                </copy> 
     68 
     69                <mkdir dir="${build.dir}/${mplayer.package}" /> 
     70 
     71                <ftp action="get" depends="yes" verbose="yes" server="ftp1.mplayerhq.hu" remotedir="/MPlayer/releases" userid="anonymous" password="jlee@iriverter.thestatictvoid.org"> 
     72                        <fileset dir="${build.dir}/${mplayer.package}"> 
     73                                <include name="win32/MPlayer-mingw32-1.0rc1.zip" /> 
     74                                <include name="codecs/windows-all-20061022.zip" /> 
     75                        </fileset> 
     76                </ftp> 
    6777        </target> 
    6878 
    6979        <target name="jar" depends="compile,resources"> 
    7080                <mkdir dir="${jar.dir}" /> 
    71                 <jar destfile="${jar.dir}/iriverter.jar" basedir="${build.dir}" /> 
     81                <jar destfile="${jar.dir}/iriverter.jar" basedir="${build.dir}" includes="${package}/**" /> 
     82                <jar destfile="${jar.dir}/mplayer-win32.jar" basedir="${build.dir}" includes="${mplayer.package}/win32/**" /> 
     83                <jar destfile="${jar.dir}/codecs-win32.jar" basedir="${build.dir}" includes="${mplayer.package}/codecs/**" /> 
    7284        </target> 
    7385 
     
    8395                 
    8496                <copy todir="${dist.dir}"> 
    85                         <fileset file="${jar.dir}/iriverter.jar" /> 
     97                        <fileset dir="${jar.dir}" includes="*.jar" /> 
    8698                        <fileset dir="${web.dir}" /> 
    8799                        <fileset dir="${basedir}" includes="${doc.dir}/**" /> 
  • trunk/src/org/thestaticvoid/iriverter/Converter.java

    r143 r146  
    320320                progressDialogInfo.setStatus("Gathering information about the input video..."); 
    321321                 
    322                 MPlayerInfo info = new MPlayerInfo("dvd://" + dvdInfo.getTitle(), dvdInfo.getDrive(), ConverterOptions.getMPlayerPath()); 
     322                MPlayerInfo info = new MPlayerInfo("dvd://" + dvdInfo.getTitle(), dvdInfo.getDrive(), mplayerPath); 
    323323                 
    324324                List commandList = prepareBaseCommandList("dvd://" + dvdInfo.getTitle(), dvdInfo.getOutputVideo(), info); 
  • trunk/src/org/thestaticvoid/iriverter/ConverterOptions.java

    r142 r146  
    258258        } 
    259259         
    260         public static String getMPlayerSource() { 
    261                 String mplayerSource = readOption("mplayerSource"); 
    262                 if (mplayerSource.equals("")) 
    263                         if (System.getProperty("os.name").indexOf("Windows") >= 0) 
    264                                 return "download"; 
    265                         else 
    266                                 return "local"; 
    267                  
    268                 return mplayerSource; 
    269         } 
    270          
    271         public static void setMPlayerSource(String mplayerSource) { 
    272                 writeOption("mplayerSource", mplayerSource); 
    273         } 
    274          
    275         public static boolean getDownloadExtraCodecs() { 
    276                 String downloadExtraCodecs = readOption("downloadExtraCodecs"); 
    277                 if (downloadExtraCodecs.equals("")) 
    278                         return false; 
    279                  
    280                 return downloadExtraCodecs.equals("true"); 
    281         } 
    282          
    283         public static void setDownloadExtraCodecs(boolean downloadExtraCodecs) { 
    284                 writeOption("downloadExtraCodecs", "" + downloadExtraCodecs); 
    285         } 
    286          
    287         public static boolean getKeepUpdated() { 
    288                 String keepUpdated = readOption("keepUpdated"); 
    289                 if (keepUpdated.equals("")) 
    290                         return true; 
    291                  
    292                 return keepUpdated.equals("true"); 
    293         } 
    294          
    295         public static void setKeepUpdated(boolean keepUpdated) { 
    296                 writeOption("keepUpdated", "" + keepUpdated); 
    297         } 
    298          
    299260        public static String getMPlayerPath() { 
    300261                String mplayerPath = readOption("mplayerPath"); 
    301262                if (mplayerPath.equals("") || !new File(mplayerPath).isDirectory()) 
    302263                        if (System.getProperty("os.name").indexOf("Windows") >= 0) 
    303                                 return "."; 
     264                                return ConverterOptions.CONF_DIR + File.separator + "mplayer"; 
    304265                        else 
    305266                                return "/usr/bin"; 
  • trunk/src/org/thestaticvoid/iriverter/ConverterUI.java

    r145 r146  
    6161                shell.setLayout(gridLayout); 
    6262                 
    63                 extractResources(); 
     63                extractResources("/org/thestaticvoid/iriverter/resources.zip", ConverterOptions.CONF_DIR.toString()); 
     64                extractResources("/hu/mplayerhq/win32/MPlayer-mingw32-1.0rc1.zip", ConverterOptions.CONF_DIR.toString()); 
     65                File mplayerDir = new File(ConverterOptions.CONF_DIR + File.separator + "mplayer"); 
     66                extractResources("/hu/mplayerhq/codecs/windows-all-20061022.zip", mplayerDir.toString()); 
     67                new File(mplayerDir, "windows-all-20061022").renameTo(new File(mplayerDir, "codecs")); 
     68                 
    6469                setupMenus(); 
    6570                setupToolBar(); 
     
    275280                 
    276281                mplayerPath = new MenuItem(advancedOptionsMenu, SWT.PUSH); 
     282                if (System.getProperty("os.name").indexOf("Windows") >= 0) 
     283                        mplayerPath.setMenu(null); 
    277284                mplayerPath.setText("&MPlayer Path..."); 
    278285                mplayerPath.addSelectionListener(this); 
     
    303310        } 
    304311         
    305         public void extractResources() { 
    306                 ZipInputStream in = new ZipInputStream(getClass().getResourceAsStream("resources.zip")); 
     312        public void extractResources(String resourceName, String toDir) { 
     313                InputStream inputStream = getClass().getResourceAsStream(resourceName); 
     314                if (inputStream == null) 
     315                        return; 
     316                 
     317                ZipInputStream in = new ZipInputStream(inputStream); 
    307318                 
    308319                try { 
    309320                        ZipEntry entry; 
    310321                        while ((entry = in.getNextEntry()) != null) { 
    311                                 File extractedFile = new File(ConverterOptions.CONF_DIR + File.separator + entry.getName()); 
     322                                File extractedFile = new File(toDir + File.separator + entry.getName()); 
    312323                                if (entry.isDirectory() && !extractedFile.exists()) 
    313324                                        extractedFile.mkdirs(); 
     
    397408                                        canceled = true; 
    398409                                } catch (MPlayerNotFoundException mpe) { 
    399                                         canceled = new MPlayerPathDialog(shell, SWT.NONE).open()
     410                                        canceled = new MPlayerPathDialog(shell).open() == null
    400411                                } 
    401412                } 
     
    418429                                                canceled = true; 
    419430                                        } catch (MPlayerNotFoundException mpe) { 
    420                                                 canceled = new MPlayerPathDialog(shell, SWT.NONE).open()
     431                                                canceled = new MPlayerPathDialog(shell).open() == null
    421432                                        } 
    422433                        } 
     
    534545                 
    535546                if (e.getSource() == mplayerPath) { 
    536                         new MPlayerPathDialog(shell, SWT.NONE).open(); 
     547                        new MPlayerPathDialog(shell).open(); 
    537548                } 
    538549                 
  • trunk/src/org/thestaticvoid/iriverter/DVD.java

    r143 r146  
    250250                                                canceled = true; 
    251251                                        } catch (MPlayerNotFoundException mpe) { 
    252                                                 canceled = new MPlayerPathDialog(getParent().getShell(), SWT.NONE).open()
     252                                                canceled = new MPlayerPathDialog(getParent().getShell()).open() == null
    253253                                        } 
    254254                        } 
     
    343343                                canceled = true; 
    344344                        } catch (MPlayerNotFoundException mpe) { 
    345                                 canceled = new MPlayerPathDialog(getParent().getShell(), SWT.NONE).open()
     345                                canceled = new MPlayerPathDialog(getParent().getShell()).open() == null
    346346                                if (canceled) 
    347347                                        progressDialog.close(); 
  • trunk/src/org/thestaticvoid/iriverter/MPlayerPathDialog.java

    r142 r146  
    2222package org.thestaticvoid.iriverter; 
    2323 
    24 import org.eclipse.swt.*; 
    2524import org.eclipse.swt.widgets.*; 
    26 import org.eclipse.swt.events.*; 
    27 import org.eclipse.swt.layout.*; 
    28 import org.eclipse.swt.graphics.*; 
    2925 
    30 public class MPlayerPathDialog extends Dialog implements SelectionListener { 
    31         private Shell shell; 
    32         private Button download, extraCodecs, keepUpdated, local, localDirSelect, cancel, ok; 
    33         private Text localDir; 
    34         private boolean canceled; 
    35          
    36         public MPlayerPathDialog(Shell parent, int style) { 
    37                 super(parent, style); 
     26public class MPlayerPathDialog extends DirectoryDialog { 
     27        public MPlayerPathDialog(Shell shell) { 
     28                super(shell); 
    3829        } 
    3930         
    40         public boolean open() { 
    41                 shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    42                 shell.setText("MPlayer Path"); 
    43                 GridLayout gridLayout = new GridLayout(); 
    44                 gridLayout.horizontalSpacing = 6; 
    45                 gridLayout.verticalSpacing = 6; 
    46                 gridLayout.marginHeight = 12; 
    47                 gridLayout.marginWidth = 12; 
    48                 shell.setLayout(gridLayout); 
     31        public String open() { 
     32                setFilterPath(ConverterOptions.getMPlayerPath()); 
     33                setText("MPlayer Path"); 
     34                setMessage("Select the path to MPlayer"); 
     35                String directory = open(); 
     36                if (directory != null) 
     37                        ConverterOptions.setMPlayerPath(directory); 
    4938                 
    50                 Label audioSyncLabel = new Label(shell, SWT.NONE); 
    51                 audioSyncLabel.setText("MPlayer Path"); 
    52                 FontData[] fontData = audioSyncLabel.getFont().getFontData(); 
    53                 fontData[0].setStyle(SWT.BOLD); 
    54                 audioSyncLabel.setFont(new Font(getParent().getDisplay(), fontData)); 
    55                  
    56                 Composite downloadComposite = new Composite(shell, SWT.RADIO); 
    57                 gridLayout = new GridLayout(); 
    58                 gridLayout.horizontalSpacing = 6; 
    59                 gridLayout.verticalSpacing = 3; 
    60                 gridLayout.marginHeight = 0; 
    61                 gridLayout.marginWidth = 0; 
    62                 downloadComposite.setLayout(gridLayout); 
    63                  
    64                 download = new Button(downloadComposite, SWT.RADIO); 
    65                 download.setText("Attempt to download MPlayer from the Internet"); 
    66                 download.addSelectionListener(this); 
    67                  
    68                 extraCodecs = new Button(downloadComposite, SWT.CHECK); 
    69                 extraCodecs.setText("Also download non-free codecs"); 
    70                 extraCodecs.setSelection(ConverterOptions.getDownloadExtraCodecs()); 
    71                 GridData gridData = new GridData(); 
    72                 gridData.horizontalIndent = 24; 
    73                 extraCodecs.setLayoutData(gridData); 
    74                  
    75                 keepUpdated = new Button(downloadComposite, SWT.CHECK); 
    76                 keepUpdated.setText("Keep updated"); 
    77                 keepUpdated.setSelection(ConverterOptions.getKeepUpdated()); 
    78                 gridData = new GridData(); 
    79                 gridData.horizontalIndent = 24; 
    80                 keepUpdated.setLayoutData(gridData); 
    81                  
    82                 Composite localComposite = new Composite(shell, SWT.NONE); 
    83                 gridLayout = new GridLayout(); 
    84                 gridLayout.horizontalSpacing = 6; 
    85                 gridLayout.verticalSpacing = 3; 
    86                 gridLayout.marginHeight = 0; 
    87                 gridLayout.marginWidth = 0; 
    88                 gridLayout.numColumns = 2; 
    89                 localComposite.setLayout(gridLayout); 
    90                 localComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
    91                  
    92                 local = new Button(localComposite, SWT.RADIO); 
    93                 local.setText("Use MPlayer installed locally in:"); 
    94                 gridData = new GridData(); 
    95                 gridData.horizontalSpan = 2; 
    96                 local.setLayoutData(gridData); 
    97                 local.addSelectionListener(this); 
    98                  
    99                 localDir = new Text(localComposite, SWT.BORDER); 
    100                 gridData = new GridData(GridData.FILL_HORIZONTAL); 
    101                 gridData.horizontalIndent = 24; 
    102                 localDir.setLayoutData(gridData); 
    103                  
    104                 localDirSelect = new Button(localComposite, SWT.PUSH); 
    105                 localDirSelect.setText("Select"); 
    106                 gridData = new GridData(); 
    107                 gridData.widthHint = 75; 
    108                 localDirSelect.setLayoutData(gridData); 
    109                  
    110                 Composite dismissComposite = new Composite(shell, SWT.NONE); 
    111                 dismissComposite.setLayout(new RowLayout()); 
    112                 gridData = new GridData(); 
    113                 gridData.horizontalAlignment = SWT.RIGHT; 
    114                 dismissComposite.setLayoutData(gridData); 
    115                  
    116                 cancel = new Button(dismissComposite, SWT.PUSH); 
    117                 cancel.setText("Cancel"); 
    118                 RowData rowData = new RowData(); 
    119                 rowData.width = 75; 
    120                 cancel.setLayoutData(rowData); 
    121                 cancel.addSelectionListener(this); 
    122                  
    123                 ok = new Button(dismissComposite, SWT.PUSH); 
    124                 ok.setText("OK"); 
    125                 rowData = new RowData(); 
    126                 rowData.width = 75; 
    127                 ok.setLayoutData(rowData); 
    128                 ok.addSelectionListener(this); 
    129                  
    130                 if (System.getProperty("os.name").indexOf("Windows") == -1) { 
    131                         download.setEnabled(false); 
    132                         extraCodecs.setEnabled(false); 
    133                         keepUpdated.setEnabled(false); 
    134                 } 
    135                  
    136                 if (ConverterOptions.getMPlayerSource().equals("download")) { 
    137                         download.setSelection(true); 
    138                         localDir.setEnabled(false); 
    139                         localDirSelect.setEnabled(false); 
    140                 } else { 
    141                         local.setSelection(true); 
    142                         extraCodecs.setEnabled(false); 
    143                         localDir.setText(ConverterOptions.getMPlayerPath()); 
    144                 } 
    145                  
    146                 shell.pack(); 
    147                 shell.setSize(450, shell.getSize().y); 
    148                 shell.open(); 
    149                 while (!shell.isDisposed()) 
    150                         if (!getParent().getDisplay().readAndDispatch()) 
    151                                 getParent().getDisplay().sleep(); 
    152                  
    153                 return canceled; 
    154         } 
    155          
    156         public void widgetDefaultSelected(SelectionEvent event) { 
    157                 widgetSelected(event); 
    158         } 
    159          
    160         public void widgetSelected(SelectionEvent event) { 
    161                 if (event.getSource() == download) { 
    162                         extraCodecs.setEnabled(true); 
    163                         keepUpdated.setEnabled(true); 
    164                         local.setSelection(false); 
    165                         localDir.setEnabled(false); 
    166                         localDirSelect.setEnabled(false); 
    167                 } 
    168                  
    169                 if (event.getSource() == local) { 
    170                         download.setSelection(false); 
    171                         extraCodecs.setEnabled(false); 
    172                         keepUpdated.setEnabled(false); 
    173                         localDir.setEnabled(true); 
    174                         localDirSelect.setEnabled(true); 
    175                 } 
    176                  
    177                 if (event.getSource() == cancel) { 
    178                         canceled = true; 
    179                         shell.dispose(); 
    180                 } 
     39                return directory; 
    18140        } 
    18241} 
  • trunk/src/org/thestaticvoid/iriverter/ManualSplit.java

    r143 r146  
    190190                                                canceled = true; 
    191191                                        } catch (MPlayerNotFoundException mpe) { 
    192                                                 canceled = new MPlayerPathDialog(getParent().getShell(), SWT.NONE).open()
     192                                                canceled = new MPlayerPathDialog(getParent().getShell()).open() == null
    193193                                        } 
    194194                        } 
  • trunk/web/iriverter.jnlp

    r144 r146  
    11<?xml version="1.0" encoding="utf-8"?> 
    22<jnlp spec="1.0+" 
    3         codebase="http://iriverter.thestaticvoid.org/dist
     3        codebase="http://iriverter.thestaticvoid.org/dist/latest
    44        href="iriverter.jnlp"> 
    55        <information> 
     
    2828                <nativelib href="swt-native-win32-win32-x86.jar" /> 
    2929                <jar href="swt-win32-win32-x86.jar" /> 
     30                <jar href="mplayer-win32.jar" /> 
     31                <jar href="codecs-win32.jar" /> 
    3032        </resources> 
    3133