danger.media
Interface PlayableMedia

All Known Subinterfaces:
PlayableAudio, PlayableVideo
All Known Implementing Classes:
BufferedStream, Sequence, Sound, Stream, Tone, Video


public interface PlayableMedia

The PlayableMedia interface provides methods which are common to all media objects, including transport control, looping, positional control, and notification callbacks.


Field Summary
static int DEFAULT_PRIORITY
          Priority default, which is PRIORITY_5.
static int PRIORITY_1
          Priority level 1.
static int PRIORITY_2
          Priority level 2.
static int PRIORITY_3
          Priority level 3.
static int PRIORITY_4
          Priority level 3.
static int PRIORITY_5
          Priority level 4.
 
Method Summary
 void destroy()
          Free memory associated with this object.
 int getCurrentLoopNumber()
          Gets the number of times the looped media has looped back to the loop start.
 int getLoopCount()
          Gets the loop count; which is the total number of times an object is played.
 int getMarkerCount()
          Deprecated. - use MarkableMedia.getMarkerCount() instead.
 int getMarkerID(int index)
          Deprecated. - use MarkableMedia.getMarkerIDByIndex(int) instead.
 String getMarkerName(int index)
          Deprecated. - use MarkableMedia.getMarkerNameByIndex(int) instead.
 int getMarkerPosition(int index)
          Deprecated. - use MarkableMedia.getMarkerPositionByIndex(int) instead.
 int getMediaType()
          Returns file type of media.
 int getMillisecondLength()
          Get length in milliseconds of object's media.
 int getMillisecondPosition()
          Get the current playback position of a object in milliseconds.
 int getPlaybackRate()
          Get the playback rate of the media. 100 is default rate.
 int getPriority()
          Get media priority level.
 int getUniqueID()
          Return runtime ID.
 boolean isDone()
          Returns true if object has finished playing.
 boolean isLoaded()
          Returns true if object is loaded and ready to be played.
 boolean isLoopingEnabled()
          Return whether looping is enabled (set by a call to setLoopingEnabled(boolean)).
 boolean isPaused()
          Returns true if paused.
 boolean isPlaying()
          Returns true if object is playing.
 void pause()
          Pause object.
 void resume()
          Will resume object if paused.
 void setDoneCallbackEvent(Event done)
          Set the event that is called when this media is finished.
 void setDoneCallbackEvent(Event done, boolean doEventOnce)
          Set the event that is called when this media is finished.
 void setLoopCount(int loopCount)
          Sets the loop count; which is the total number of times an object is played.
 void setLoopingEnabled(boolean on)
          Enable looping.
 void setMillisecondPosition(int mSec)
          Set the current playback position of object in milliseconds.
 void setPlaybackRate(int newRate)
          Set the playback rate of the media.
 void setPositionCallbackEvent(Event event, int position)
          Set an event that is called when this media reaches the given position during playback.
 void setPositionToMarker(int markerID)
          Deprecated. - use MarkableMedia.setPositionToMarkerByID(int) instead.
 void setPriority(int priority)
          Set media priority level.
 void setStoppedCallbackEvent(Event stopped)
          Set the event that is called when this media is stopped by stop().
 void setStoppedCallbackEvent(Event stopped, boolean doEventOnce)
          Set the event that is called when this media is stopped by stop().
 void startPlaying()
          Start media playback with default attributes.
 void startPlaying(int attributes)
          Start media playback with specified attributes.
 void stopPlaying()
          Stop media playback.
 

Field Detail

PRIORITY_1

static final int PRIORITY_1
Priority level 1.

Since:
3.0
See Also:
Constant Field Values

PRIORITY_2

static final int PRIORITY_2
Priority level 2.

Since:
3.0
See Also:
Constant Field Values

PRIORITY_3

static final int PRIORITY_3
Priority level 3.

Since:
3.0
See Also:
Constant Field Values

PRIORITY_4

static final int PRIORITY_4
Priority level 3.

Since:
3.0
See Also:
Constant Field Values

PRIORITY_5

static final int PRIORITY_5
Priority level 4.

Since:
3.0
See Also:
Constant Field Values

DEFAULT_PRIORITY

static final int DEFAULT_PRIORITY
Priority default, which is PRIORITY_5. Used with setPriority(int). Higher values are higher priority.

Since:
3.0
See Also:
Constant Field Values
Method Detail

destroy

void destroy()
Free memory associated with this object. You cannot make any additional calls on this object, and it should be nulled immediately upon return from this method.


getMillisecondLength

int getMillisecondLength()
Get length in milliseconds of object's media.


setMillisecondPosition

void setMillisecondPosition(int mSec)
Set the current playback position of object in milliseconds. Must call after starting object.

Parameters:
mSec - position in media to seek to

getMillisecondPosition

int getMillisecondPosition()
Get the current playback position of a object in milliseconds.


isPlaying

boolean isPlaying()
Returns true if object is playing.


isLoaded

boolean isLoaded()
Returns true if object is loaded and ready to be played.


getMediaType

int getMediaType()
Returns file type of media.


startPlaying

void startPlaying()
Start media playback with default attributes.


startPlaying

void startPlaying(int attributes)
Start media playback with specified attributes.

Parameters:
attributes - - class-specific attributes applied to this playback

stopPlaying

void stopPlaying()
Stop media playback.


isDone

boolean isDone()
Returns true if object has finished playing.


isPaused

boolean isPaused()
Returns true if paused.


pause

void pause()
Pause object.


resume

void resume()
Will resume object if paused. Does nothing if already resumed.


getUniqueID

int getUniqueID()
Return runtime ID. Unique every time object is started


setLoopingEnabled

void setLoopingEnabled(boolean on)
Enable looping. This will use the loop counter mLoopCount, which is either set via a call to setLoopCount(int) or is 0 (loop forever) by default.

Parameters:
on - enable or disable looping.

isLoopingEnabled

boolean isLoopingEnabled()
Return whether looping is enabled (set by a call to setLoopingEnabled(boolean)).

Returns:
enabled - true or false.

setLoopCount

void setLoopCount(int loopCount)
Sets the loop count; which is the total number of times an object is played.

Parameters:
loopCount - - total number of times to play; 0 means loop forever.

getLoopCount

int getLoopCount()
Gets the loop count; which is the total number of times an object is played.


getCurrentLoopNumber

int getCurrentLoopNumber()
Gets the number of times the looped media has looped back to the loop start.


getMarkerCount

int getMarkerCount()
Deprecated. - use MarkableMedia.getMarkerCount() instead.

Gets the number of markers contained by the currently loaded media. These can be video, MIDI, or audio markers.


getMarkerID

int getMarkerID(int index)
Deprecated. - use MarkableMedia.getMarkerIDByIndex(int) instead.

Return the integer ID associated with the marker at the given index.


getMarkerName

String getMarkerName(int index)
Deprecated. - use MarkableMedia.getMarkerNameByIndex(int) instead.

Return the name associated with the marker at the given index. May return null.


getMarkerPosition

int getMarkerPosition(int index)
Deprecated. - use MarkableMedia.getMarkerPositionByIndex(int) instead.

Return the position in milliseconds of the marker at the given index.


setPositionToMarker

void setPositionToMarker(int markerID)
Deprecated. - use MarkableMedia.setPositionToMarkerByID(int) instead.

Set the media playback position to the position associated with the marker with the given markerID.


setPositionCallbackEvent

void setPositionCallbackEvent(Event event,
                              int position)
Set an event that is called when this media reaches the given position during playback. Any number of these may be set. Set event to null to disable a given position's callback.

Parameters:
event - - event to be posted
position - - time in milliseconds at which the event should be posted

setDoneCallbackEvent

void setDoneCallbackEvent(Event done)
Set the event that is called when this media is finished.

Parameters:
done - - event to be posted

setDoneCallbackEvent

void setDoneCallbackEvent(Event done,
                          boolean doEventOnce)
Set the event that is called when this media is finished.

Parameters:
done - - event to be posted
doEventOnce - - if true, callback only called once for a given playback

setStoppedCallbackEvent

void setStoppedCallbackEvent(Event stopped)
Set the event that is called when this media is stopped by stop().

Parameters:
stopped - - event to be posted

setStoppedCallbackEvent

void setStoppedCallbackEvent(Event stopped,
                             boolean doEventOnce)
Set the event that is called when this media is stopped by stop().

Parameters:
stopped - - event to be posted
doEventOnce - - if true, callback only called once for a given playback

setPriority

void setPriority(int priority)
Set media priority level.

Parameters:
priority - - priority level for media

getPriority

int getPriority()
Get media priority level.

Returns:
current priority level

setPlaybackRate

void setPlaybackRate(int newRate)
Set the playback rate of the media.

Parameters:
newRate - - new playback rate; 100 is default rate.

getPlaybackRate

int getPlaybackRate()
Get the playback rate of the media. 100 is default rate.