Package org.gstreamer.elements

Examples of org.gstreamer.elements.PlayBin2


  private PlayBin2 playbin;
  private ArrayList<JukeboxChangedTrackListener> trackChangedListener = new ArrayList<JukeboxChangedTrackListener>();
  public Player(Bus.EOS jukebox,Bus.ERROR jb, JukeboxChangedTrackListener l){
    trackChangedListener.add(l);
    Gst.init("AudioPlayerMetadata", new String[0]);
    playbin  = new PlayBin2("AudioPlayer");
    playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
    playbin.getBus().connect(jukebox);
      playbin.getBus().connect(jb);
  }
View Full Code Here


import org.gstreamer.elements.PlayBin2;

public class AudioPlayer {
  public static void main(String[] args) {
    args = Gst.init("AudioPlayerMetadata", args);
    PlayBin2 playbin = new PlayBin2("AudioPlayer");
    playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
    playbin.setInputFile(new File("/home/artur/Musik/Kram-Musik/Misfits Alben/Misfits.10 ALBEN/Famous Monsters/16 Hunting Humans The Misfits Famous Monsters Rock 192kbps.wma"));

    playbin.getBus().connect(new Bus.TAG() {

      public void tagsFound(GstObject source, TagList tagList) {
        for (String tagName : tagList.getTagNames()) {
          for (Object tagData : tagList.getValues(tagName)) {
            if (!"".equals(tagData)) {
              System.out.printf("%s: %s\n", tagName, tagData);
            }
          }
        }
      }
    });
    playbin.play();
//    playbin.pause();
//    playbin.seek(ClockTime.fromSeconds(5));
//    playbin.play();
    Gst.main();
    playbin.setState(State.NULL);
  }
View Full Code Here

        gstVideoComponent = new VideoComponent();
        synchronized (playbinLock) {
            if (gstPlaybin2 != null) {
                gstPlaybin2.dispose();
            }
            gstPlaybin2 = new PlayBin2("VideoPlayer"); //NON-NLS
            gstPlaybin2.setVideoSink(gstVideoComponent.getElement());

            videoPanel.removeAll();

View Full Code Here

                    NbBundle.getMessage(this.getClass(), "GstVideoPanel.exception.problemFile.msg", file.getName()));
        }

        // set up a PlayBin2 object
        RGBDataSink videoSink = new RGBDataSink("rgb", rgbListener); //NON-NLS
        PlayBin2 playbin = new PlayBin2("VideoFrameCapture"); //NON-NLS
        playbin.setInputFile(file);
        playbin.setVideoSink(videoSink);

        // this is necessary to get a valid duration value
        StateChangeReturn ret = playbin.play();
        if (ret == StateChangeReturn.FAILURE) {
            // add this file to the set of known bad ones
            badVideoFiles.add(file.getName());
            throw new Exception(NbBundle.getMessage(this.getClass(), "GstVideoPanel.exception.problemPlay.msg"));
        }
        ret = playbin.pause();
        if (ret == StateChangeReturn.FAILURE) {
            // add this file to the set of known bad ones
            badVideoFiles.add(file.getName());
            throw new Exception(NbBundle.getMessage(this.getClass(), "GstVideoPanel.exception.problemPause.msg"));
        }
        playbin.getState();

        // get the duration of the video
        TimeUnit unit = TimeUnit.MILLISECONDS;
        long myDurationMillis = playbin.queryDuration(unit);
        if (myDurationMillis <= 0) {
            return frames;
        }

        // calculate the number of frames to capture
        int numFramesToGet = numFrames;
        long frameInterval = myDurationMillis / numFrames;
        if (frameInterval < MIN_FRAME_INTERVAL_MILLIS) {
            numFramesToGet = 1;
        }

        // for each timeStamp, grap a frame
        for (int i = 0; i < numFramesToGet; ++i) {
            long timeStamp = i * frameInterval;

            ret = playbin.pause();
            if (ret == StateChangeReturn.FAILURE) {
                // add this file to the set of known bad ones
                badVideoFiles.add(file.getName());
                throw new Exception(
                        NbBundle.getMessage(this.getClass(), "GstVideoPanel.exception.problemPauseCaptFrame.msg"));
            }
            playbin.getState();

            //System.out.println("Seeking to " + timeStamp + "milliseconds.");
            if (!playbin.seek(timeStamp, unit)) {
                logger.log(Level.INFO, "There was a problem seeking to " + timeStamp + " " + unit.name().toLowerCase()); //NON-NLS
            }
           
            ret = playbin.play();
            if (ret == StateChangeReturn.FAILURE) {
                // add this file to the set of known bad ones
                badVideoFiles.add(file.getName());
                throw new Exception(
                        NbBundle.getMessage(this.getClass(), "GstVideoPanel.exception.problemPlayCaptFrame.msg"));
            }

            // wait for FrameCaptureRGBListener to finish
            synchronized(lock) {
                try {
                    lock.wait(FRAME_CAPTURE_TIMEOUT_MILLIS);
                } catch (InterruptedException e) {
                    logger.log(Level.INFO, "InterruptedException occurred while waiting for frame capture.", e); //NON-NLS
                }
            }
            Image image = rgbListener.getImage();

            ret = playbin.stop();
            if (ret == StateChangeReturn.FAILURE) {
                // add this file to the set of known bad ones
                badVideoFiles.add(file.getName());
                throw new Exception(
                        NbBundle.getMessage(this.getClass(), "GstVideoPanel.exception.problemStopCaptFrame.msg"));
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.