Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. public class PlayerPanel extends JPanel{
  2. private File vlcInstallPath = new File("C:\Program Files\VideoLAN\VLC");
  3.  
  4. private EmbeddedMediaPlayer player;
  5.  
  6. public PlayerPanel() {
  7. NativeLibrary.addSearchPath("libvlc", vlcInstallPath.getAbsolutePath());
  8. EmbeddedMediaPlayerComponent videoCanvas = new EmbeddedMediaPlayerComponent();
  9. this.setLayout(new BorderLayout());
  10. this.add(videoCanvas, BorderLayout.CENTER);
  11. this.player = videoCanvas.getMediaPlayer();
  12. }
  13.  
  14. public void play(String media) {
  15. player.prepareMedia(media);
  16. player.parseMedia();
  17. player.play();
  18. }
  19.  
  20. }
  21.  
  22. class VideoPlayer extends JFrame {
  23.  
  24. public VideoPlayer() {
  25. PlayerPanel player = new PlayerPanel();
  26. this.setTitle("Swing Video Player");
  27. this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  28. this.setLayout(new BorderLayout());
  29. this.setSize(640, 480);
  30. this.setLocationRelativeTo(null);
  31. this.add(player, BorderLayout.CENTER);
  32. this.validate();
  33. this.setVisible(true);
  34.  
  35. player.play("C:\Users\pc\Documents\NetBeansProjects\DesktopApplication2\src\Wildlife.wmv");
  36. }
  37.  
  38. public static void main(String[] args) {
  39. new VideoPlayer();
  40. }
  41. }
  42.  
  43. this.setTitle("Swing Video Player");
  44. this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  45. this.setLayout(new BorderLayout());
  46. this.setSize(640, 480);
  47. this.setLocationRelativeTo(null);
  48. this.add(player, BorderLayout.CENTER);
  49. this.validate();
  50. this.setVisible(true);
  51.  
  52. player.play("C:\Users\Public\Videos\Sample Videos\Wildlife.wmv");
  53. player.jb.addActionListener(al);
  54. }
  55. ActionListener al = new ActionListener() {
  56. @Override
  57. public void actionPerformed(ActionEvent e) {
  58. player.stop();
  59. }
  60. };
  61.  
  62. public static void main(String[] args) {
  63. new VideoPlayer();
  64. }
  65.  
  66. private File vlcInstallPath = new File("C:\Program Files\VideoLAN\VLC");
  67. private EmbeddedMediaPlayer player;
  68. public static JButton jb = new JButton("STOP");
  69.  
  70. public PlayerPanel() {
  71. NativeLibrary.addSearchPath("libvlc", vlcInstallPath.getAbsolutePath());
  72. EmbeddedMediaPlayerComponent videoCanvas = new EmbeddedMediaPlayerComponent();
  73.  
  74. this.setLayout(new BorderLayout());
  75. this.add(videoCanvas, BorderLayout.CENTER);
  76. this.add(jb, BorderLayout.SOUTH);
  77. this.player = videoCanvas.getMediaPlayer();
  78. }
  79.  
  80. public void play(String media) {
  81. player.prepareMedia(media);
  82. player.parseMedia();
  83. player.play();
  84. }
  85.  
  86. public void stop() {
  87. player.stop();
  88. }
  89.  
  90. player.play("C:\Users\pc\Documents\NetBeansProjects\DesktopApplication2\src\Wildlife.wmv");
  91. player.jb.addActionListener(al);
  92. }
  93. ActionListener al=new ActionListener() {
  94.  
  95. public void actionPerformed(ActionEvent ae) {
  96. //To change body of generated methods, choose Tools | Templates.
  97. player.stop();
  98. dispose();
  99. new EmployeeRegister().setVisible(true);
  100. }
  101. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement