Package org.gstreamer.swing

Examples of org.gstreamer.swing.VideoPlayer$TogglePlayAction


        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame frame = new JFrame("Swing Video Player");
                JLayeredPane layeredPane = new JLayeredPane();
                frame.add(layeredPane, BorderLayout.CENTER);
                final VideoPlayer full = new VideoPlayer(files[0]);
                full.setPreferredSize(new Dimension(1024, 768));
                full.setControlsVisible(true);
                full.setBounds(0, 0, 640, 480);
                full.getMediaPlayer().play();
                layeredPane.add(full, JLayeredPane.DEFAULT_LAYER);
                layeredPane.setPreferredSize(new Dimension(640, 480));
               
                // Add a panel just above the main video
                final JPanel pip = new JPanel();
                pip.setOpaque(false);
                pip.setBackground(new Color(0, 0, 0, 0));
                layeredPane.add(pip, new Integer(1));
                pip.setBounds(0, 0, 640, 480);
                pip.setLayout(new FlowLayout());
               
                // Add a button panel above that
                final JPanel controls = new JPanel();
                controls.setBounds(full.getBounds());
                controls.setLayout(new BorderLayout());
                layeredPane.add(controls, Integer.valueOf(2));
                final JPanel buttonPanel = new JPanel();
                buttonPanel.setLayout(new BorderLayout());
                JButton quit = new JButton("Quit");
                buttonPanel.add(quit, BorderLayout.WEST);
                quit.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent arg0) {
                        System.exit(0);
                    }
                });
                quit.setOpaque(false);
                controls.add(buttonPanel, BorderLayout.NORTH);
                controls.setOpaque(false);
                buttonPanel.setOpaque(false);
               
                layeredPane.addComponentListener(new ComponentAdapter() {

                    @Override
                    public void componentResized(ComponentEvent e) {
                        JComponent c = (JComponent) e.getComponent();
                        Rectangle r = c.getBounds();
                        full.setBounds(r);
                        pip.setBounds(r);
                        controls.setBounds(r);
                        c.revalidate();
                    }
                   
                });
                for (int i = 1; i < files.length; ++i) {
                    String uri = files[i];                   
                    final VideoPlayer player = new VideoPlayer(uri);
                    player.setPreferredSize(new Dimension(200, 150));
                    player.setOpacity(0.4f);
                    player.setOpaque(false);
                    player.setControlsVisible(false);
                    Pipeline pipe = player.getMediaPlayer().getPipeline();
                    // Turn off sound - otherwise everything goes slow.
                    if (pipe instanceof PlayBin2) {
                        ((PlayBin2) pipe).setAudioSink(ElementFactory.make("fakesink", "audio"));
                    }
                    pip.add(player);
                    // Stagger the start times, so gstreamer doesn't choke
                    javax.swing.Timer timer = new javax.swing.Timer(1000 * i, new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            player.getMediaPlayer().play();
                        }
                    });
                    timer.setRepeats(false);
                    timer.start();
                }
View Full Code Here


        SwingUtilities.invokeLater(new Runnable() {
            public void run() {

                JFrame frame = new JFrame("Swing Test");

                final VideoPlayer player = new VideoPlayer(file);
                player.setPreferredSize(new Dimension(640, 480));
                player.setControlsVisible(true);
                player.getMediaPlayer().setPlaylist(playList);
                frame.add(player, BorderLayout.CENTER);
                player.getMediaPlayer().play();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
            }
        });
View Full Code Here

                    frame.setClosable(true);
                    frame.setIconifiable(true);
                    frame.setMaximizable(true);
                   
                    frame.setLocation(i * 100, i * 100);
                    final VideoPlayer player = new VideoPlayer(file);
                    player.setPreferredSize(new Dimension(640, 480));
                    player.setControlsVisible(true);
                    frame.add(player, BorderLayout.CENTER);
                    frame.pack();
                    panel.add(frame);
                    frame.setVisible(true);
                    javax.swing.Timer timer = new javax.swing.Timer(5000 * i, new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            player.getMediaPlayer().play();
                        }
                    });
                    timer.setRepeats(false);
                    timer.start();
                }
View Full Code Here

                //frame.add(new JScrollPane(panel), BorderLayout.CENTER);
                frame.add(panel);
                panel.setLayout(new FlowLayout(FlowLayout.LEFT));
                for (int i = 0; i < files.length; ++i) {
                    final File file = files[i];
                    final VideoPlayer player = new VideoPlayer(file);
                    player.setPreferredSize(new Dimension(160, 100));
                    player.setControlsVisible(false);
                    JButton button = new JButton(file.getName());
                    button.setLayout(new BoxLayout(button, BoxLayout.Y_AXIS));
                    button.add(player);
                  
                    button.addActionListener(new ActionListener() {
                        boolean playing = true;
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("Button " + file.getName() + " clicked");
                            if (!playing) {
                                player.getMediaPlayer().play();
                                playing = true;
                            } else {
                                playing = false;
                                player.getMediaPlayer().pause();
                            }
                        }
                    });
                    button.setVerticalTextPosition(SwingConstants.BOTTOM);
                    JLabel label = new JLabel(file.getName());
                    label.setHorizontalTextPosition(SwingConstants.CENTER);
                    label.setHorizontalAlignment(SwingConstants.CENTER);
                    JPanel box = new JPanel();
                    box.setLayout(new BorderLayout());
                    box.add(label, BorderLayout.SOUTH);
                    box.setOpaque(false);
                    button.add(box);
                    panel.add(button);
                    // Delay the startup a bit so gstreamer doesn't get swamped
                    javax.swing.Timer timer = new javax.swing.Timer(2000 * i, new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            player.getMediaPlayer().play();
                        }
                    });
                    timer.setRepeats(false);
                    timer.start();
                }
View Full Code Here

                    frame.setIconifiable(true);
                    frame.setMaximizable(true);
                   
                    frame.setLocation(i * 100, i * 100);
                    final float alpha = 0.6f;
                    final VideoPlayer player = new VideoPlayer(file) {

                        private static final long serialVersionUID = 4925431893247320169L;

                        protected void paintComponent(Graphics g) {
                            Graphics2D g2d = (Graphics2D) g.create();
                            g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
                            g2d.setColor(Color.BLACK);
                            g2d.fillRect(0, 0, getWidth(), getHeight());
                            g2d.dispose();
                        }
                    };
                    player.setPreferredSize(new Dimension(400, 250));
                    player.setControlsVisible(true);
                    player.setOpaque(false);
                    player.setOpacity(alpha);
                    Pipeline pipe = player.getMediaPlayer().getPipeline();
                    if (pipe instanceof PlayBin2) {
                        ((PlayBin2) pipe).setAudioSink(ElementFactory.make("fakesink", "audio"));
                    }
                   
                    frame.setOpaque(false);
                    frame.setContentPane(player);
                    frame.pack();
                   
                    frame.setVisible(true);
                    javax.swing.Timer timer = new javax.swing.Timer(5000 * i, new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            player.getMediaPlayer().play();
                        }
                    });
                    timer.setRepeats(false);
                    timer.start();
                }
View Full Code Here

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
               
                JFrame frame = new JFrame("Swing Test");
               
                final VideoPlayer player = new VideoPlayer(file);
                player.setPreferredSize(new Dimension(640, 480));
                player.setControlsVisible(true);
                player.getMediaPlayer().setPlaylist(playList);
                frame.add(player, BorderLayout.CENTER);
                player.getMediaPlayer().play();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
           
        });
View Full Code Here

TOP

Related Classes of org.gstreamer.swing.VideoPlayer$TogglePlayAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.