Package org.gstreamer.elements

Examples of org.gstreamer.elements.PlayBin2


public class PlayBinMediaPlayer extends PipelineMediaPlayer {
    private static final Executor defaultExec = Executors.newSingleThreadExecutor();
    private final PlayBin2 playbin;

    public PlayBinMediaPlayer(String name, Executor eventExecutor) {
        super(new PlayBin2(name), eventExecutor);
        playbin = (PlayBin2) getPipeline();
       
    }
View Full Code Here


       
        args = Gst.init("Simple Player", args);
        for (String s : args) {
            System.out.println("Leftover arg=" + s);
        }
        player = new PlayBin2("Example Player");
        player.setInputFile(new File(args[0]));
        Bus bus = player.getBus();
        tags = new TagList();
        bus.connect(new Bus.TAG() {
            public void tagsFound(GstObject source, TagList tagList) {
View Full Code Here

                frame.add(canvas, BorderLayout.CENTER);               
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
                               
                PlayBin2 player = new PlayBin2("Overlay Player");               
                player.setInputFile(new File(file));
                bus = player.getBus();
               
                bus.connect(new Bus.ERROR() {
                    public void errorMessage(GstObject source, int code, String message) {
                        System.out.println("Error: code=" + code + " message=" + message);
                    }
                });
                final Element videoSink = ElementFactory.make(overlayFactory, "overlay video sink");
                player.setVideoSink(videoSink);
                //
                // Setting the overlay window ID is supposed to be done from a sync handler
                // but that doesn't work on windows
                //
                if (!Platform.isWindows()) {
                    bus.setSyncHandler(new BusSyncHandler() {

                        public BusSyncReply syncMessage(Message msg) {
                            Structure s = msg.getStructure();
                            if (s == null || !s.hasName("prepare-xwindow-id")) {
                                return BusSyncReply.PASS;
                            }
                            XOverlay.wrap(videoSink).setWindowHandle(canvas);
                            return BusSyncReply.DROP;
                        }
                    });
                } else {
                    XOverlay.wrap(videoSink).setWindowHandle(canvas);
                }
                player.play();      
           
        });
    }
View Full Code Here

        }
        //
        // Create a PlayBin2 to play the media file.  A PlayBin2 is a Pipeline that
        // creates all the needed elements and automatically links them together.
        //
        PlayBin2 playbin = new PlayBin2("AudioPlayer");
       
        // Make sure a video window does not appear.
        playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
       
        // Set the file to play
        playbin.setInputFile(new File(args[0]));
       
        // Listen for metadata (tags)
        playbin.getBus().connect(new Bus.TAG() {

            public void tagsFound(GstObject source, TagList tagList) {
                for (String tagName : tagList.getTagNames()) {
                    // Each tag can have multiple values, so print them all.
                    for (Object tagData : tagList.getValues(tagName)) {
                        System.out.printf("[%s]=%s\n", tagName, tagData);
                    }
                }
            }
        });
       
        // Start the pipeline playing
        playbin.play();
        Gst.main();
       
        // Clean up (gstreamer requires elements to be in State.NULL before disposal)
        playbin.stop();
    }
View Full Code Here

        }
        //
        // Create a PlayBin2 to play the media file.  A PlayBin2 is a Pipeline that
        // creates all the needed elements and automatically links them together.
        //
        PlayBin2 playbin = new PlayBin2("AudioPlayer");
       
        // Make sure a video window does not appear.
        playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
       
        // Set the file to play
        playbin.setInputFile(new File(args[0]));
       
        // Start the pipeline playing
        playbin.play();
        Gst.main();
       
        // Clean up (gstreamer requires elements to be in State.NULL before disposal)
        playbin.stop();
    }
View Full Code Here

        }
        //
        // Instead of using a playbin, it would be possible to use a pipe
        // a typefind element and a demux and wire them up manually.
        //
        final PlayBin2 pipe = new PlayBin2(progname);
        pipe.setInputFile(new File(args[0]));
        FakeSink audio = (FakeSink) ElementFactory.make("fakesink", "audio-sink");
        FakeSink video = (FakeSink) ElementFactory.make("fakesink", "video-sink");
        pipe.setAudioSink(audio);
        pipe.setVideoSink(video);
       
        pipe.getBus().connect(new Bus.TAG() {
            public void tagsFound(GstObject source, TagList tagList) {
                for (String tag : tagList.getTagNames()) {
                    System.out.println("Found tag " + tag + " = "
                            + tagList.getValue(tag, 0));
                }
            }
        });
       
        //
        // In theory, an ASYNC_DONE from the pipeline corresponds with the demux
        // completing parsing the media file
        //
        pipe.getBus().connect(new Bus.ASYNC_DONE() {
            public void asyncDone(GstObject source) {
                pipe.stop();
                done.countDown();
            }
        });
        audio.set("signal-handoffs", true);
        video.set("signal-handoffs", true);
       
        //
        // As soon as data starts to flow, it means all tags have been found
        //
        BaseSink.HANDOFF handoff = new BaseSink.HANDOFF() {
            public void handoff(BaseSink sink, Buffer buffer, Pad pad) {
                pipe.stop();
                done.countDown();
            }
        };
        audio.connect(handoff);
        video.connect(handoff);
       
        // Start the pipeline playing
        pipe.pause();
        try {
            done.await();
        } catch (InterruptedException ex) {
        }
        pipe.stop();
    }
View Full Code Here

        //
        args = Gst.init("AudioPanorama", args);
        PanoramaSink sink = new PanoramaSink("panorama sink");
        Pipeline pipe;
        if (args.length > 0) {
            PlayBin2 playbin = new PlayBin2("AudioPanorama");

            playbin.setInputFile(new File(args[0]));
           
            playbin.setAudioSink(sink);
            pipe = playbin;
        } else {
            pipe = new Pipeline("AudioPanorama");

            Element src = ElementFactory.make("audiotestsrc", "src");
View Full Code Here

       
        //
        // Create a PlayBin2 to play the media file.  A PlayBin2 is a Pipeline that
        // creates all the needed elements and automatically links them together.
        //
        final PlayBin2 playbin = new PlayBin2("VideoPlayer");
       
        // Set the file to play
        playbin.setInputFile(new File(args[0]));

        //
        // We now have to do the rest in the context of the Swing EDT, because
        // we are constructing Swing components.
        //
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                //
                // A VideoComponent displays video in a lightweight swing component
                //
                VideoComponent videoComponent = new VideoComponent();
               
                // Add the video component as the playbin video output
                playbin.setVideoSink(videoComponent.getElement());
               
                // Start the pipeline playing
                playbin.play();
               
                //
                // Initialise the top-level frame and add the video component
                //
                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);
            }
        });
       
        //
        // Wait until Gst.quit() is called.
        //
        Gst.main();
        playbin.stop();
    }
View Full Code Here

        }
        //
        // Create a PlayBin2 to play the media file.  A PlayBin2 is a Pipeline that
        // creates all the needed elements and automatically links them together.
        //
        final PlayBin2 playbin = new PlayBin2("BusMessages");
       
        // Make sure a video window does not appear.
        playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
       
        // Set the file to play
        playbin.setInputFile(new File(args[0]));
       
        // Listen for end-of-stream (i.e. when the media has finished)
        playbin.getBus().connect(new Bus.EOS() {

            public void endOfStream(GstObject source) {
                System.out.println("Finished playing file");
                Gst.quit();
            }
        });
       
        // Listen for any error conditions
        playbin.getBus().connect(new Bus.ERROR() {
            public void errorMessage(GstObject source, int code, String message) {
                System.out.println("Error occurred: " + message);
                Gst.quit();
            }
        });
       
        // Listen for metadata (tags)
        playbin.getBus().connect(new Bus.TAG() {

            public void tagsFound(GstObject source, TagList tagList) {
                for (String tagName : tagList.getTagNames()) {
                    // Each tag can have multiple values, so print them all.
                    for (Object tagData : tagList.getValues(tagName)) {
                        System.out.printf("[%s]=%s\n", tagName, tagData);
                    }
                }
            }
        });
       
        // Listen for state-changed messages
        playbin.getBus().connect(new Bus.STATE_CHANGED() {

            public void stateChanged(GstObject source, State old, State current, State pending) {
                if (source == playbin) {
                    System.out.println("Pipeline state changed from " + old + " to " + current);
                }
            }
        });
       
        // Start the pipeline playing
        playbin.play();
        Gst.main();
        // Clean up (gstreamer requires elements to be in State.NULL before disposal)
        playbin.stop();
        Gst.deinit();
    }
View Full Code Here

  private PlayBin2 playbin;
  private Thread locationThread;
  public GST(JukeboxChangedTrackListener l, AudioPositionListener p, PlayerAbstractionLayer master) {
    super(l, p, master);
    Gst.init("AudioPlayerMetadata", new String[0]);
    playbin  = new PlayBin2("AudioPlayer");
    playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
    playbin.getBus().connect((EOS)this);
      playbin.getBus().connect((ERROR)this);
      locationThread = new Thread(new Runnable() {
View Full Code Here

TOP

Related Classes of org.gstreamer.elements.PlayBin2

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.