Package javax.media

Examples of javax.media.Player


    /**
     * This method is run when PlayerDriver is an applet.
     */
    public void init() {
        String   media;
  Player  player;

        // Get the media filename
        if((media = getParameter("MEDIA")) == null) {
            System.err.println("Invalid MEDIA file parameter");
            return;
        }

        JFrame f = new JFrame(media);
        JPanel playerpanel = new JPanel();

  try {
      URL url = new URL("file:///" + new File(media).getCanonicalPath());
      player = Manager.createRealizedPlayer(url);
            add(playerpanel);
            player.start();
        }
  catch (MalformedURLException mfe) {
      System.out.println("Bad URL");
  }
  catch (IOException ioe) {
View Full Code Here


    else {
        System.err.println("      The stream comes from: " + participant.getCNAME());
    }

    // create a player by passing datasource to the Media Manager
    Player p = javax.media.Manager.createPlayer(ds);
    if (p == null)
        return;

    p.addControllerListener(this);
    p.realize();
    PlayerWindow pw = new PlayerWindow(p, stream);
    playerWindows.addElement(pw);

    // Notify intialize() that a new stream had arrived.
    synchronized (dataSync) {
View Full Code Here

    /**
     * ControllerListener for the Players.
     */
    public synchronized void controllerUpdate(ControllerEvent ce) {

  Player p = (Player)ce.getSourceController();

  if (p == null)
      return;

  // Get this when the internal players are realized.
  if (ce instanceof RealizeCompleteEvent) {
      PlayerWindow pw = find(p);
      if (pw == null) {
    // Some strange happened.
    System.err.println("Internal error!");
    System.exit(-1);
      }
      pw.initialize();
      pw.setVisible(true);
      p.start();
  }

  if (ce instanceof ControllerErrorEvent) {
      p.removeControllerListener(this);
      PlayerWindow pw = find(p);
      if (pw != null) {
    pw.close()
    playerWindows.removeElement(pw);
      }
View Full Code Here

     * @exception  ClassCastException
     *             If the Controller is not a Player
     */
    public boolean blockingStart() {
        setState(Controller.Started);
        Player player = (Player)controller;
        player.start();
        return waitForState();
    }
View Full Code Here

    String url = "rtp://192.168.1.1:22224/audio/16";

    MediaLocator mrl = new MediaLocator(url);

    // Create a player for this rtp session
    Player player = null;
    try
    {
      player = Manager.createPlayer(mrl);
    } catch (NoPlayerException e)
    {
      e.printStackTrace();
      System.exit(-1);
    } catch (MalformedURLException e)
    {
      e.printStackTrace();
      System.exit(-1);
    } catch (IOException e)
    {
      e.printStackTrace();
      System.exit(-1);
    }

    if (player != null)
    {
      System.out.println("Player created.");
      player.realize();
      // wait for realizing
      while (player.getState() != Player.Realized)
      {
        try
        {
          Thread.sleep(10);
        } catch (InterruptedException e)
        {
          e.printStackTrace();
        }
      }
      System.out.println("Starting player");
      player.start();
    } else
    {
      System.err.println("Player doesn't created.");
      System.exit(-1);
    }
View Full Code Here

    /**
     * ControllerListener for the Players.
     */
    public synchronized void controllerUpdate(ControllerEvent ce) {

  Player p = (Player)ce.getSourceController();

  if (p == null)
      return;

  // Get this when the internal players are realized.
  if (ce instanceof RealizeCompleteEvent) {
      PlayerWindow pw = find(p);
      if (pw == null) {
    // Some strange happened.
    System.err.println("Internal error!");
    System.exit(-1);
      }
      pw.initialize();
      pw.setVisible(true);
      p.start();
  }

  if (ce instanceof ControllerErrorEvent) {
      p.removeControllerListener(this);
      PlayerWindow pw = find(p);
      if (pw != null) {
    pw.close()
    playerWindows.removeElement(pw);
      }
View Full Code Here

    /**
     * Open a media file.
     */
    public void openFile(String filename) {
  String mediaFile = filename;
  Player player = null;
  // URL for our media file
  URL url = null;
  try {
      // Create an url from the file name and the url to the
      // document containing this applet.
View Full Code Here

        Vector v = new Vector();

        //  Create a Vector of Players
        for(int i = 0; i < args.length; i++) {
            try {
                Player p = Manager.createPlayer(
                    Utility.appArgToMediaLocator(args[i]) );
                new StateWaiter(p).blockingRealize();
                v.addElement(p);
            } catch(Exception e) {
                System.out.println( "Could not create Player for " + args[i]);
View Full Code Here

  */
    public void rewind() {
  for (int i = 0; i < tracks.getNumberOfTracks(); i++) {
      Track track = tracks.getTrack(i);
      if (track.isAssigned()) {
          Player player = track.getPlayer();
          player.setMediaTime(new Time(0));
      }
  }
    }
View Full Code Here

    public void stop() {
  timer.stop();
  for (int i = 0; i < tracks.getNumberOfTracks(); i++) {
      Track track = tracks.getTrack(i);
      if (track.isAssigned()) {
          Player player = track.getPlayer();
                if (player.getTargetState() == Controller.Started) {
        player.stop();
          }
      }
  }
    }
View Full Code Here

TOP

Related Classes of javax.media.Player

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.