Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VideoTest {
- private static PlayBin2 playbin;
- private static File file;
- private static JFileChooser fc=new JFileChooser();
- public VideoTest()
- {
- }
- public static void main(String[] args)
- {
- args = Gst.init("VideoTest", args);
- playbin = new PlayBin2("VideoTest");
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- VideoComponent videoComponent = new VideoComponent();
- org.gstreamer.Element videosink = videoComponent.getElement();
- playbin.setVideoSink(videosink);
- // Now create a JFrame to display the video output
- JMenuBar menuBar = new JMenuBar();
- JMenu menu = new JMenu("File");
- menu.setHorizontalAlignment(SwingConstants.CENTER);
- menuBar.add(menu);
- JMenuItem menuItem = new JMenuItem("Open");
- menu.add(menuItem);
- JFrame frame = new JFrame("Swing Video Test");
- frame.getContentPane().add(menuBar, BorderLayout.NORTH);
- frame.getContentPane().add(videoComponent, BorderLayout.CENTER);
- frame.setPreferredSize(new Dimension(720, 576));
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.pack();
- frame.setVisible(true);
- menuItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- if(fc.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
- playbin.setInputFile(fc.getSelectedFile());
- }
- }
- });
- // Start the pipeline processing
- playbin.stop();
- playbin.setState(State.PLAYING);
- }
- });
- Gst.main();
- playbin.setState(State.NULL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement