This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 29th, 2012  |  syntax: Java  |  size: 1.46 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package main;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.io.File;
  6.  
  7. import javax.swing.JFrame;
  8. import javax.swing.SwingUtilities;
  9. import javax.swing.WindowConstants;
  10.  
  11. import org.gstreamer.Gst;
  12. import org.gstreamer.State;
  13. import org.gstreamer.elements.PlayBin2;
  14. import org.gstreamer.swing.VideoComponent;
  15.  
  16. public class Java2DTest
  17. {
  18.     public Java2DTest()
  19.     {
  20.     }
  21.    
  22.     public static void main(String[] args)
  23.     {
  24.         try
  25.                 {
  26.                         LibraryLoaderImpl.getInstance().load();
  27.                 } catch (Exception e)
  28.                 {
  29.                         e.printStackTrace();
  30.                 }
  31.        
  32.         Gst.init("VideoPlayer", null);
  33.         final PlayBin2 playbin = new PlayBin2("VideoPlayer");
  34.         playbin.setInputFile(new File("dmc4_1024x512.ogv"));
  35.  
  36.         SwingUtilities.invokeLater(new Runnable() {
  37.  
  38.             public void run() {
  39.                 VideoComponent videoComponent = new VideoComponent();
  40.                 playbin.setVideoSink(videoComponent.getElement());
  41.  
  42.                 JFrame frame = new JFrame("VideoPlayer");
  43.                 frame.getContentPane().add(videoComponent, BorderLayout.CENTER);
  44.                 frame.setPreferredSize(new Dimension(640, 480));
  45.                 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  46.                 frame.pack();
  47.                 frame.setVisible(true);
  48.                 playbin.setState(State.PLAYING);
  49.             }
  50.         });
  51.         Gst.main();
  52.         playbin.setState(State.NULL);
  53.     }
  54. }
clone this paste RAW Paste Data