Advertisement
Guest User

Untitled

a guest
May 6th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. public class VideoTest {
  2.  
  3. private static PlayBin2 playbin;
  4. private static File file;
  5. private static JFileChooser fc=new JFileChooser();
  6. public VideoTest()
  7. {
  8.  
  9. }
  10.  
  11. public static void main(String[] args)
  12. {
  13. args = Gst.init("VideoTest", args);
  14. playbin = new PlayBin2("VideoTest");
  15.  
  16.  
  17. SwingUtilities.invokeLater(new Runnable() {
  18.  
  19. public void run() {
  20. VideoComponent videoComponent = new VideoComponent();
  21. org.gstreamer.Element videosink = videoComponent.getElement();
  22. playbin.setVideoSink(videosink);
  23.  
  24. // Now create a JFrame to display the video output
  25. JMenuBar menuBar = new JMenuBar();
  26.  
  27. JMenu menu = new JMenu("File");
  28. menu.setHorizontalAlignment(SwingConstants.CENTER);
  29. menuBar.add(menu);
  30.  
  31. JMenuItem menuItem = new JMenuItem("Open");
  32. menu.add(menuItem);
  33. JFrame frame = new JFrame("Swing Video Test");
  34. frame.getContentPane().add(menuBar, BorderLayout.NORTH);
  35. frame.getContentPane().add(videoComponent, BorderLayout.CENTER);
  36. frame.setPreferredSize(new Dimension(720, 576));
  37. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  38. frame.pack();
  39.  
  40. frame.setVisible(true);
  41.  
  42. menuItem.addActionListener(new ActionListener() {
  43. public void actionPerformed(ActionEvent arg0) {
  44.  
  45. if(fc.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
  46.  
  47. playbin.setInputFile(fc.getSelectedFile());
  48.  
  49. }
  50. }
  51. });
  52. // Start the pipeline processing
  53. playbin.stop();
  54. playbin.setState(State.PLAYING);
  55. }
  56. });
  57.  
  58. Gst.main();
  59. playbin.setState(State.NULL);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement