Logo Search packages:      
Sourcecode: libjlayer-java version File versions  Download package

boolean javazoom::jl::player::advanced::AdvancedPlayer::play ( int  frames  )  throws JavaLayerException [inline]

Plays a number of MPEG audio frames.

Parameters:
frames The number of frames to play.
Returns:
true if the last frame was played, or false if there are more frames.

Definition at line 82 of file AdvancedPlayer.java.

References audio, close(), closed, complete, createEvent(), decodeFrame(), javazoom::jl::player::AudioDevice::flush(), listener, javazoom::jl::player::advanced::PlaybackListener::playbackFinished(), and javazoom::jl::player::advanced::PlaybackListener::playbackStarted().

      {
            boolean ret = true;

            // report to listener
            if(listener != null) listener.playbackStarted(createEvent(PlaybackEvent.STARTED));

            while (frames-- > 0 && ret)
            {
                  ret = decodeFrame();
            }

//          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();
                        }

                        // report to listener
                        if(listener != null) listener.playbackFinished(createEvent(out, PlaybackEvent.STOPPED));
                  }
            }
            return ret;
      }


Generated by  Doxygen 1.6.0   Back to index