com.lightdev.lib.audio
Interface PlayerListener


public interface PlayerListener

This interface has to be implemented by classes interested to be notified of events fired by a Player thread.

Classes implementing this interface can either ignore decoded bytes coming from the player or use them to drive devices such as a spectrum analyzer or VU meter. In cases where a class implementing this interface consumes decoded bytes to drive other devices it has to signal the Player that it does so via method consumesDecodedBytes(). The Player takes this indication to not play audio directly in such case. Instead the Player only passes decoded bytes to the consumer and expects that consumer to pass back decoded bytes through method Player.write() which actually triggers audio to be played.

Version:
Version 1, August 28, 2004
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the GNU General Public License, for details see file 'license.txt' in the distribution package of this software
See Also:
Player

Method Summary
 int cdb()
          Classes implementing this interface need to use this method to signal whether or not they consume bytes from method decoded().
 void decoded(Player p, byte[] buf, int byteCount)
          handle the fact that an amount of bytes has been decoded Implementations of this method can use the decoded bytes to drive additional devices such as a spectrum analyzer for instance before passing the decoded bytes back to the player.
 void exception(Player p, Exception ex)
          notify listeners of an exception during playing
 void progress(Player p, long progressValue)
          notify listeners of the current player progress
 void stateChanged(Player p, int fromStatus, int toStatus)
          notify listeners that the status of a given Player thread changed
 

Method Detail

stateChanged


void stateChanged(Player p,

                  int fromStatus,

                  int toStatus)
notify listeners that the status of a given Player thread changed

Parameters:
p - Player the player whose status changed
fromStatus - int the status changed from
toStatus - int the status changed to

progress


void progress(Player p,

              long progressValue)
notify listeners of the current player progress

Parameters:
p - Player the player that fired the event
progressValue - long the microseconds played so far

exception


void exception(Player p,

               Exception ex)
notify listeners of an exception during playing

Parameters:
p - Player the player that fired the event
ex - Exception the exception that occurred

decoded


void decoded(Player p,

             byte[] buf,

             int byteCount)

handle the fact that an amount of bytes has been decoded

Implementations of this method can use the decoded bytes to drive additional devices such as a spectrum analyzer for instance before passing the decoded bytes back to the player.

Parameters:
p - Player the player that fired the event
buf - byte[] the decoded bytes
byteCount - int the number of bytes in buf

cdb


int cdb()

Classes implementing this interface need to use this method to signal whether or not they consume bytes from method decoded(). When class returns true in this method, it is required to call method Player.write() to actually play audio.

Returns:
true, when this class consumes decoded bytes and calls method Player.write() accordingly

Copyright (c) 2004, 2005 Ulrich Hilger