Search in sources :

Example 1 with AudioFilePlayerTopComponent

use of blue.ui.core.soundFile.AudioFilePlayerTopComponent in project blue by kunstmusik.

the class RenderToDiskAndPlayAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    BlueProject project = BlueProjectManager.getInstance().getCurrentProject();
    if (project != null) {
        BlueData data = project.getData();
        if (data != null) {
            RenderToDiskUtility.getInstance().renderToDisk(data, f -> {
                DiskRenderSettings settings = DiskRenderSettings.getInstance();
                if (settings.externalPlayCommandEnabled) {
                    String command = settings.externalPlayCommand;
                    command = command.replaceAll("\\$outfile", f.getAbsolutePath());
                    try {
                        if (System.getProperty("os.name").contains("Windows")) {
                            Runtime.getRuntime().exec(command);
                        } else {
                            String[] cmdArray = ProcessConsole.splitCommandString(command);
                            Runtime.getRuntime().exec(cmdArray);
                        }
                        System.out.println(command);
                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Could not run command: " + command, "Error", JOptionPane.ERROR_MESSAGE);
                        System.err.println("[" + BlueSystem.getString("message.error") + "] - " + ex.getLocalizedMessage());
                        ex.printStackTrace();
                    }
                } else {
                    SwingUtilities.invokeLater(() -> {
                        AudioFilePlayerTopComponent tc = (AudioFilePlayerTopComponent) WindowManager.getDefault().findTopComponent("AudioFilePlayerTopComponent");
                        tc.setAudioFile(f);
                    });
                }
            });
        }
    }
}
Also used : BlueData(blue.BlueData) BlueProject(blue.projects.BlueProject) DiskRenderSettings(blue.settings.DiskRenderSettings) AudioFilePlayerTopComponent(blue.ui.core.soundFile.AudioFilePlayerTopComponent)

Aggregations

BlueData (blue.BlueData)1 BlueProject (blue.projects.BlueProject)1 DiskRenderSettings (blue.settings.DiskRenderSettings)1 AudioFilePlayerTopComponent (blue.ui.core.soundFile.AudioFilePlayerTopComponent)1