Package videoplayer.player

Source Code of videoplayer.player.VideoPlayer

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package videoplayer.player;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.net.URI;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import org.gstreamer.Gst;
import org.gstreamer.State;
import org.gstreamer.elements.PlayBin;
import org.gstreamer.swing.VideoComponent;

/**
*
* @author duo
*/
public class VideoPlayer {
    public static void main(String[] args) {
        args = Gst.init("VideoPlayer", args);
        final PlayBin playbin = new PlayBin("VideoPlayer");
        try{
        playbin.setURI(new URI("v4l2://"));
        System.out.println("v4l2!");
        } catch(Exception e) {
          playbin.setInputFile(new File(args[0]));
        System.out.println("video ...");
        }

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                VideoComponent videoComponent = new VideoComponent();
                playbin.setVideoSink(videoComponent.getElement());

                JFrame frame = new JFrame("VideoPlayer");
                frame.getContentPane().add(videoComponent, BorderLayout.CENTER);
                frame.setPreferredSize(new Dimension(640, 480));
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
                playbin.setState(State.PLAYING);
            }
        });
        Gst.main();
        playbin.setState(State.NULL);
    }

}
TOP

Related Classes of videoplayer.player.VideoPlayer

TOP
Copyright © 2018 www.massapi.com. 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.