diff --git a/src/forge/GuiDisplay3.java b/src/forge/GuiDisplay3.java index 7c93d37c3a1..3d880497b2b 100644 --- a/src/forge/GuiDisplay3.java +++ b/src/forge/GuiDisplay3.java @@ -167,8 +167,8 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon private void addMenu() { Object[] obj = { HUMAN_GRAVEYARD_ACTION, HUMAN_REMOVED_ACTION, HUMAN_FLASHBACK_ACTION, COMPUTER_GRAVEYARD_ACTION, - COMPUTER_REMOVED_ACTION, GuiDisplay3.eotCheckboxForMenu, new JSeparator(), - ErrorViewer.ALL_THREADS_ACTION, new JSeparator(), CONCEDE_ACTION}; + COMPUTER_REMOVED_ACTION, new JSeparator(), GuiDisplay3.eotCheckboxForMenu, GuiDisplay3.playsoundCheckboxForMenu, new JSeparator(), + ErrorViewer.ALL_THREADS_ACTION, CONCEDE_ACTION}; JMenu gameMenu = new JMenu(ForgeProps.getLocalized(MENU_BAR.MENU.TITLE)); for(Object o:obj) { @@ -1148,9 +1148,10 @@ public class GuiDisplay3 extends JFrame implements Display, NewConstants, NewCon public boolean stopEOT() { return eotCheckboxForMenu.isSelected(); - } + } public static JCheckBoxMenuItem eotCheckboxForMenu = new JCheckBoxMenuItem("Stop at End of Turn", false); + public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", true); MultiSplitPane pane = new MultiSplitPane(); JButton cancelButton = new JButton(); diff --git a/src/forge/MP3Player.java b/src/forge/MP3Player.java index b7fcd390bf3..f95d3f645cd 100644 --- a/src/forge/MP3Player.java +++ b/src/forge/MP3Player.java @@ -16,20 +16,24 @@ public class MP3Player implements NewConstants{ private Player player; private InputStream is; + private File file; /** Creates a new instance of MP3Player */ public MP3Player(String filename) { + File base = ForgeProps.getFile(SOUND_BASE); + file = new File(base, filename); + if(GuiDisplay3.playsoundCheckboxForMenu.isSelected()&&file.exists()){ try { - // Create an InputStream to the file - File base = ForgeProps.getFile(SOUND_BASE); - File file = new File(base, filename); + // Create an InputStream to the file is = new FileInputStream(file); } catch (Exception e) { e.printStackTrace(); } + } } public void play() { + if(GuiDisplay3.playsoundCheckboxForMenu.isSelected()&&file.exists()){ try { player = new Player(is); PlayerThread pt = new PlayerThread(); @@ -37,6 +41,7 @@ public class MP3Player implements NewConstants{ } catch (Exception e) { e.printStackTrace(); } + } } class PlayerThread extends Thread {