Package javazoom.jl.player

Examples of javazoom.jl.player.AudioDevice


    }

//    if (!ret)
    {
      // last frame, ensure all data flushed to the audio device.
      AudioDevice out = audio;
      if (out != null)
      {
//        System.out.println(audio.getPosition());
        out.flush();
//        System.out.println(audio.getPosition());
        synchronized (this)
        {
          complete = (!closed);
          close();
View Full Code Here


   * Cloases this player. Any audio currently playing is stopped
   * immediately.
   */
  public synchronized void close()
  {
    AudioDevice out = audio;
    if (out != null)
    {
      closed = true;
      audio = null;
      // this may fail, so ensure object state is set up before
      // calling this method.
      out.close();
      lastPosition = out.getPosition();
      try
      {
        bitstream.close();
      }
      catch (BitstreamException ex)
View Full Code Here

   */
  protected boolean decodeFrame() throws JavaLayerException
  {
    try
    {
      AudioDevice out = audio;
      if (out == null) return false;

      Header h = bitstream.readFrame();
      if (h == null) return false;

      // sample buffer set when decoder constructed
      SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);

      synchronized (this)
      {
        out = audio;
        if(out != null)
        {
          out.write(output.getBuffer(), 0, output.getBufferLength());
        }
      }

      bitstream.closeFrame();
    }
View Full Code Here

  public void playStreaming(String path) {
    if (isPlaying)
      return;
    try {
      AudioDevice dev = getAudioDevice();
      player = new Player(getURLInputStream(path), dev);
      isPlaying = true;
      player.play();
      in.close();
      LOGGER.debug("------------------------------------------------- FIM DO PLAY");
View Full Code Here

    }

//    if (!ret)
    {
      // last frame, ensure all data flushed to the audio device.
      AudioDevice out = audio;
      if (out != null)
      {
       
//        System.out.println(audio.getPosition());
        out.flush();
//        System.out.println(audio.getPosition());
        synchronized (this)
        {
          complete = (!closed);
          close();
View Full Code Here

   */
  public int getPosition()
  {
    int position = lastPosition;
   
    AudioDevice out = audio;   
    if (out!=null)
    {
      position = out.getPosition()
    }
    return position;
  }
View Full Code Here

   * Closes this player. Any audio currently playing is stopped
   * immediately.
   */
  public synchronized void close()
  {
    AudioDevice out = audio;
    if (out != null)
    {
      closed = true;
      audio = null;
      // this may fail, so ensure object state is set up before
      // calling this method.
      out.close();
      lastPosition = out.getPosition();
      try
      {
        bitstream.close();
      }
      catch (BitstreamException ex)
View Full Code Here

   */
  protected boolean decodeFrame() throws JavaLayerException
  {
    try
    {
      AudioDevice out = audio;
      if (out == null) return false;

      Header h = bitstream.readFrame();
      if (h == null) return false;

      // sample buffer set when decoder constructed
      SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);
      short amplitude = 0;
      for(int i = 1; i < output.getBuffer().length; i++) {
          output.getBuffer()[i] = (short) (output.getBuffer()[i] * volume);
       
        if(output.getBuffer()[i] > amplitude) {
          amplitude = output.getBuffer()[i];
        }
      }
     
     
      if(amplitudeListener != null) {
        amplitudeListener.getAmplitude(amplitude);
      }
     
      synchronized (this)
      {
        out = audio;
        if(out != null)
        {
          out.write(output.getBuffer(), 0, output.getBufferLength());
        }
      }

      bitstream.closeFrame();
    }
View Full Code Here

    /** Implements callable interface: Loads the AudioDevice and returns it*/
    public AudioDevice call(){
      try{
        // Get AudioDevice from Registry
        FactoryRegistry factoryregistry = FactoryRegistry.systemRegistry();
        AudioDevice audio = factoryregistry.createAudioDevice();
        return audio;
      }
      catch(Exception ee){
        System.err.println("Could not load audio driver");
        ee.printStackTrace();
View Full Code Here

TOP

Related Classes of javazoom.jl.player.AudioDevice

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.