⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mediafilespanel.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                moveUpButton.setEnabled(false);            } else {                masterMB.setEnabled(true);                moveUpButton.setEnabled(true);            }            if (row == (currentMDCopy.size() - 1)) {                moveDownButton.setEnabled(false);            } else {                moveDownButton.setEnabled(true);            }            MediaDescriptor md = (MediaDescriptor) currentMDCopy.get(row);            if (md.mimeType.equals(MediaDescriptor.WAV_MIME_TYPE)) {                extractMB.setEnabled(true);            } else {                extractMB.setEnabled(false);            }        } else {            removeMB.setEnabled(false);            updateMB.setEnabled(false);            masterMB.setEnabled(false);            extractMB.setEnabled(false);            moveUpButton.setEnabled(false);            moveDownButton.setEnabled(false);        }        fillInfoPanel(row);    }    /**     * Sets the contents of the media file info panel. A JLabel with html     * formatting is used for the info strings, which are a kind of key-value     * pairs.     *     * @param row the source MediaDescriptor for the info,  when null empty     *        value strings are used     */    private void fillInfoPanel(int row) {        TableModel model = mediaTable.getModel();        Object masterObj = model.getValueAt(row, 5);        Object linkedObj = model.getValueAt(row, 6);        boolean isMaster = (masterObj instanceof Boolean)            ? ((Boolean) masterObj).booleanValue() : false;        boolean isLinked = (linkedObj instanceof Boolean)            ? ((Boolean) linkedObj).booleanValue() : false;        linkInfoLabel.setText("<html><table>" + "<tr><td>" +            model.getColumnName(0) + "</td><td>" +            ((model.getValueAt(row, 0) != null) ? model.getValueAt(row, 0) : "") +            "</td></tr>" + "<tr><td>" + model.getColumnName(1) + "</td><td>" +            ((model.getValueAt(row, 1) != null) ? model.getValueAt(row, 1) : "") +            "</td></tr>" + "<tr><td>" + model.getColumnName(2) + "</td><td>" +            ((model.getValueAt(row, 2) != null) ? model.getValueAt(row, 2) : "") +            "</td></tr>" + "<tr><td>" + model.getColumnName(3) + "</td><td>" +            ((model.getValueAt(row, 3) != null) ? model.getValueAt(row, 3) : "") +            "</td></tr>" + "<tr><td>" + model.getColumnName(4) + "</td><td>" +            ((model.getValueAt(row, 4) != null) ? model.getValueAt(row, 4) : "") +            "</td></tr>" + "<tr><td>" + model.getColumnName(5) + "</td><td>" +            ((model.getValueAt(row, 5) != null)            ? (isMaster ? ElanLocale.getString("LinkedFilesDialog.Label.Yes")                        : ElanLocale.getString("LinkedFilesDialog.Label.No")) : "") +            "</td></tr>" + "<tr><td>" + model.getColumnName(6) + "</td><td>" +            ((model.getValueAt(row, 6) != null)            ? (isLinked            ? ElanLocale.getString("LinkedFilesDialog.Label.StatusLinked")            : ElanLocale.getString("LinkedFilesDialog.Label.StatusMissing")) : "") +            "</td></tr>" + "</table></html>");    }    /**     * Shows a FileChhoser for a mediafile.     *     * @param mediaType DOCUMENT ME!     *     * @return the full path to a mediafile as a String, or null     */    private String chooseMediaFile(int mediaType) {        JFileChooser chooser = new JFileChooser();        if (mediaType == ElanFileFilter.MEDIA_TYPE) {            FileFilter mediaFilter = ElanFileFilter.createFileFilter(mediaType);            chooser.addChoosableFileFilter(mediaFilter);            chooser.addChoosableFileFilter(ElanFileFilter.createFileFilter(                    ElanFileFilter.MP4_TYPE));            chooser.addChoosableFileFilter(ElanFileFilter.createFileFilter(                    ElanFileFilter.QT_TYPE));            chooser.setFileFilter(mediaFilter);        } else {            chooser.addChoosableFileFilter(ElanFileFilter.createFileFilter(                    mediaType));        }        chooser.setDialogTitle(ElanLocale.getString(                "LinkedFilesDialog.SelectMediaDialog.Title"));        chooser.setApproveButtonText(ElanLocale.getString(                "LinkedFilesDialog.SelectMediaDialog.Approve"));        String dir = (String) Preferences.get("MediaDir", null);        if (dir == null) {            // user.dir is probably a better choice than home.dir?            dir = System.getProperty("user.dir");        }        chooser.setCurrentDirectory(new File(dir));        int option = chooser.showOpenDialog(this);        if (option == JFileChooser.APPROVE_OPTION) {            File selected = chooser.getSelectedFile();            if ((selected != null) && selected.exists()) {                String selectedFilePath = selected.getAbsolutePath();                String mediaDir = selected.getParent();                Preferences.set("MediaDir", mediaDir, null);                return selectedFilePath;            }        }        return null;    }    /**     * Presents an input pane for an rtsp streaming address.     * Copied from MultiFileChooser.     * @return the string/url of the new file.     */    private String chooseRemoteFile() {        Object rf = JOptionPane.showInputDialog(this,                ElanLocale.getString("Frame.ElanFrame.NewDialog.RemoteLabel"),                ElanLocale.getString("Frame.ElanFrame.NewDialog.RemoteMedia"),                JOptionPane.PLAIN_MESSAGE, null, null, "rtsp://");        if (rf == null) {            return null;        }        String url = (String) rf;        url.replace('\\', '/');        // try some simple repairs        boolean valid = true;        if (!url.startsWith("rtsp")) {            int ds = url.indexOf("//");            if (ds > -1) {                url = "rtsp:" + url.substring(ds);            } else {                url = "rtsp://" + url;            }        }        if (url.indexOf("://") != 4) {            valid = false; // do not even try to repair        }        int dot = url.lastIndexOf('.');        int slash = url.lastIndexOf('/');        if ((dot < 0) || (dot < slash) || ((dot > slash) && (slash <= 7))) {            valid = false;        }        // no use trying to check the string as an URL (doesn't know the rtsp protocol)        // or URI (accepts almost any string)        if (!valid) {            JOptionPane.showMessageDialog(this,                ElanLocale.getString("Frame.ElanFrame.NewDialog.RemoteMessage") +                url, ElanLocale.getString("Message.Error"),                JOptionPane.ERROR_MESSAGE);            addRemoteMedia();        }        return url;    }    /**     * Shows a warning/error dialog with the specified message string.     *     * @param message the message to display     */    private void showWarningDialog(String message) {        JOptionPane.showMessageDialog(this, message,            ElanLocale.getString("Message.Warning"), JOptionPane.WARNING_MESSAGE);    }    /**     * Shows a yes-no option dialog with the specified question.     *     * @param question the question     *     * @return true if the user's answer is confirmative, false otherwise     */    private boolean showOptionDialog(String question) {        int option = JOptionPane.showOptionDialog(this, question,                ElanLocale.getString("LinkedFilesDialog.Title"),                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,                new String[] {                    ElanLocale.getString("Button.Yes"),                    ElanLocale.getString("Button.No")                }, ElanLocale.getString("Button.Yes"));        return (option == JOptionPane.YES_OPTION);    }    /**     * Lets the user select a linked video file that has been the source for     * the audio file in the specified MediaDescriptor.     *     * @param forAudioMD the descriptor of the audio file     *     * @return the url of the source video file     */    private String showVideoSelectionDialog(MediaDescriptor forAudioMD) {        if (forAudioMD == null) {            return null;        }        List videos = new ArrayList();        videos.add(NO_SOURCE);        MediaDescriptor md;        for (int i = 0; i < currentMDCopy.size(); i++) {            md = (MediaDescriptor) currentMDCopy.get(i);            if (md.mimeType.equals(MediaDescriptor.MPG_MIME_TYPE)) {                videos.add(md.mediaURL);            }        }        String option = (String) JOptionPane.showInputDialog(this,                ElanLocale.getString("LinkedFilesDialog.Question.SelectSource"),                ElanLocale.getString("LinkedFilesDialog.Title"),                JOptionPane.QUESTION_MESSAGE, null, videos.toArray(), NO_SOURCE);        return option;    }    /**     * Tests the media descriptors for video files and extracted audio files     * with different offsets.  When found a warning message is displayed.     */    private void checkUnequalOffsets() {        if (currentMDCopy.size() < 2) {            return;        }        StringBuffer mesBuf = null;        MediaDescriptor amd;        MediaDescriptor vmd;        for (int i = 0; i < currentMDCopy.size(); i++) {            amd = (MediaDescriptor) currentMDCopy.get(i);            if (amd.mimeType.equals(MediaDescriptor.WAV_MIME_TYPE)) {                for (int j = 0; j < currentMDCopy.size(); j++) {                    vmd = (MediaDescriptor) currentMDCopy.get(j);                    if (MediaDescriptorUtil.isVideoType(vmd)) {                        if (vmd.mediaURL.equals(amd.extractedFrom) && (j != 0) &&                                (vmd.timeOrigin != amd.timeOrigin)) {                            // add to the list                            if (mesBuf == null) {                                mesBuf = new StringBuffer(ElanLocale.getString(                                            "LinkedFilesDialog.Message.OffsetNotEqual"));                                mesBuf.append("\n\n");                            }                            mesBuf.append("- " + vmd.mediaURL + "\n");                            mesBuf.append("- " + amd.mediaURL + "\n\n");                            break;                        }                    }                }            }        }        if (mesBuf != null) {            showWarningDialog(mesBuf.toString());        }    }    /**     * The action performed method.     *     * @param actionEvent DOCUMENT ME!     */    public void actionPerformed(ActionEvent actionEvent) {        Object source = actionEvent.getSource();        if (source == addMB) {            addMediaDescriptor();        } else if (source == removeMB) {            removeMediaDescriptor();        } else if (source == updateMB) {            updateMediaDescriptor();        } else if (source == masterMB) {            setMasterMedia();        } else if (source == extractMB) {            setExtractedFrom();        } else if (source == moveUpButton) {            moveUp();        } else if (source == moveDownButton) {            moveDown();        } else if (source == addRemoteMB) {            addRemoteMedia();        }    }    /**     * Updates some buttons after a change in the selected row.     *     * @param lse the event     *     * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)     */    public void valueChanged(ListSelectionEvent lse) {        if (!lse.getValueIsAdjusting()) {            updateUIComponents();        }    }    /**     * Updates some buttons after a change in the table model.     *     * @param tme the event     *     * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)     */    public void tableChanged(TableModelEvent tme) {        updateUIComponents();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -