增加测试声音播放按钮
This commit is contained in:
@@ -2,6 +2,7 @@ package com.sv.barcode;
|
|||||||
|
|
||||||
import com.sv.barcode.button.EnterClick;
|
import com.sv.barcode.button.EnterClick;
|
||||||
import com.sv.barcode.button.OutClick;
|
import com.sv.barcode.button.OutClick;
|
||||||
|
import com.sv.barcode.button.PlayerClick;
|
||||||
import com.sv.barcode.button.TestCodeClick;
|
import com.sv.barcode.button.TestCodeClick;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -29,12 +30,17 @@ public class ListenKeyFrame {
|
|||||||
//设置输入框大小
|
//设置输入框大小
|
||||||
JButton buttonSubmit = new JButton("验证二维码(测试专用)");
|
JButton buttonSubmit = new JButton("验证二维码(测试专用)");
|
||||||
buttonSubmit.addActionListener(new TestCodeClick(jTextField));
|
buttonSubmit.addActionListener(new TestCodeClick(jTextField));
|
||||||
|
|
||||||
|
JButton buttonPlay = new JButton("播放声音");
|
||||||
|
buttonPlay.addActionListener(new PlayerClick());
|
||||||
|
|
||||||
frame.addKeyListener(new ScanBarCode());
|
frame.addKeyListener(new ScanBarCode());
|
||||||
frame.add(label);
|
frame.add(label);
|
||||||
frame.add(buttonIn);
|
frame.add(buttonIn);
|
||||||
frame.add(buttonOut);
|
frame.add(buttonOut);
|
||||||
// frame.add(jTextField); // 注释
|
// frame.add(jTextField); // 注释
|
||||||
// frame.add(buttonSubmit); // 注释
|
// frame.add(buttonSubmit); // 注释
|
||||||
|
frame.add(buttonPlay);
|
||||||
frame.setFocusableWindowState(true);
|
frame.setFocusableWindowState(true);
|
||||||
frame.setAlwaysOnTop(true);
|
frame.setAlwaysOnTop(true);
|
||||||
// frame.setExtendedState(JFrame.MAXIMIZED_BOTH); //最大化
|
// frame.setExtendedState(JFrame.MAXIMIZED_BOTH); //最大化
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
public class EnterClick implements ActionListener {
|
public class EnterClick implements ActionListener {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ClientHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(EnterClick.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
public class OutClick implements ActionListener {
|
public class OutClick implements ActionListener {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ClientHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(OutClick.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.sv.barcode.button;
|
||||||
|
|
||||||
|
import com.sv.intergration.PlayMusicService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
public class PlayerClick implements ActionListener {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(PlayerClick.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
PlayMusicService.INSTANCE.playTest();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
public class TestCodeClick implements ActionListener {
|
public class TestCodeClick implements ActionListener {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ClientHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(TestCodeClick.class);
|
||||||
|
|
||||||
private JTextField barcode;
|
private JTextField barcode;
|
||||||
|
|
||||||
|
|||||||
@@ -35,4 +35,14 @@ public enum PlayMusicService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void playTest(){
|
||||||
|
File bye = new File("/home/venue/client/test.mp3");
|
||||||
|
if (bye.exists()){
|
||||||
|
byeVoice.addAudioFile(bye);
|
||||||
|
player.setPlayList(byeVoice);
|
||||||
|
player.play();
|
||||||
|
player.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user