public abstract class

Player

extends Object
java.lang.Object
   ↳ com.neomades.media.Player
Known Direct Subclasses

Class Overview

Player base.

This abstract class provides basic functions of a player.

See Also

Summary

Constants
long TIME_UNKNOWN Long value for unknown time
Public Methods
long getCurrentTime()
Returns the current time in milliseconds.
long getDuration()
Returns the duration of the media in milliseconds.
int getVolume()
Returns the volume level in percent (between 0 and 100).
boolean isLooping()
If the player is looping or non-looping.
boolean isMuted()
Returns if the player is muted.
boolean isPlaying()
Returns if the current player is playing
void pause()
Pauses a media (playback can be resumed with play())
void play()
Plays or resumes a media asynchronously.
void play(long startTime)
Plays a media asynchronously at the specified startTime parameter.
void prepare()
Prepare buffering the media to play.
void release()
Releases memory and media data.
void setCurrentTime(long time)
Sets the current time where the player is positioned.
void setLooping(boolean looping)
Sets the player to be looping or non-looping.
void setMuted(boolean muted)
Set the player to be muted or not.
void setPlayerListener(PlayerListener listener)
Sets a player event listener.
void setVolume(int volume)
Sets the track volume.
void stop()
Stop a media and back to the position 0 of the media.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final long TIME_UNKNOWN

Long value for unknown time

Constant Value: -1 (0xffffffffffffffff)

Public Methods

public long getCurrentTime ()

Returns the current time in milliseconds.

Returns
  • the current time

public long getDuration ()

Returns the duration of the media in milliseconds.

This function could return TIME_UNKNOWN in some cases :

  • When the media is in streaming mode
  • When the platform or the device could not read the duration

Returns
  • the duration

public int getVolume ()

Returns the volume level in percent (between 0 and 100).

Returns
  • the volume
See Also

public boolean isLooping ()

If the player is looping or non-looping.

Returns
  • true if the player is looping

public boolean isMuted ()

Returns if the player is muted.

Returns
  • if the player is muted.

public boolean isPlaying ()

Returns if the current player is playing

Returns
  • if the player is playing

public void pause ()

Pauses a media (playback can be resumed with play())

public void play ()

Plays or resumes a media asynchronously.

public void play (long startTime)

Plays a media asynchronously at the specified startTime parameter.

Parameters
startTime time where to start to play.

public void prepare ()

Prepare buffering the media to play.

public void release ()

Releases memory and media data.

The player will not be longer available after calling this method.

public void setCurrentTime (long time)

Sets the current time where the player is positioned.

Parameters
time time in milliseconds

public void setLooping (boolean looping)

Sets the player to be looping or non-looping.

Parameters
looping infinite loop or no loop

public void setMuted (boolean muted)

Set the player to be muted or not.

Parameters
muted if the player should be muted

public void setPlayerListener (PlayerListener listener)

Sets a player event listener.

Parameters
listener the player listener

public void setVolume (int volume)

Sets the track volume.

The real volume depends on two volume levels (the track volume and the main volume).

 realVolume = mainVolume x trackVolume
 

By default, the mainVolume and trackVolume are equal to 100.

If the volume given in parameter is less than zero, the volume will be 0. For values greater than 100 volume will be 100.

Parameters
volume between 0 and 100

public void stop ()

Stop a media and back to the position 0 of the media.