public abstract class JMediaPlayer
extends java.lang.Object
JMediaPlayer
- media player.
It is responsible for playing one media (audio/video) stream from the source.Modifier and Type | Class and Description |
---|---|
static interface |
JMediaPlayer.IListener
IListener - media player listener. |
static class |
JMediaPlayer.ListenerAdapter
ListenerAdapter - JMediaPlayer.IListener adapter. |
Modifier and Type | Field and Description |
---|---|
protected IAudioPlayback |
audioPlayback |
protected IAudioProcessor |
audioProcessor |
protected static JMediaPlayer.IListener |
EMPTY_LISTENER |
static java.lang.String |
EVENT_REMOTE_CLOSE
EVENT_REMOTE_CLOSE |
static java.lang.String |
EVENT_REMOTE_CONNECTED
EVENT_REMOTE_CONNECTING |
static java.lang.String |
EVENT_REMOTE_CONNECTING
EVENT_REMOTE_CONNECTING |
static java.lang.String |
EVENT_REMOTE_OPEN_FAILURE
EVENT_REMOTE_OPEN_FAILURE |
static java.lang.String |
EVENT_REMOTE_OPEN_SUCCESS
EVENT_REMOTE_OPEN_SUCCESS |
protected JMediaPlayer.IListener |
listener |
protected ILogger |
logger |
Constructor and Description |
---|
JMediaPlayer()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static JMediaPlayer |
create(boolean live,
IMediaPlayerModel model)
Creates
JMediaPlayer . |
static JMediaPlayer |
create(IMediaPlayerModel model)
Creates
JMediaPlayer . |
IMediaPlayerModel |
getModel()
Returns media player model.
|
long |
getPlaybackSkew()
Returns playback audio/video skew (in milliseconds).
|
float |
getPlaybackSpeed()
Returns playback speed.
|
boolean |
isLive()
Checks if player is playing live stream.
|
boolean |
isPaused()
Checks if player is paused.
|
boolean |
isPlaying()
Checks if player is playing.
|
boolean |
isRemote()
Checks if player is playing remote stream.
|
protected static boolean |
isZeroOffset(int[] offset)
Checks if offset values are zero.
|
protected void |
logModelExecutionException(java.lang.String method,
java.lang.Exception e,
java.lang.Object... args)
Logs model method execution exception.
|
void |
pause(boolean pause)
Pauses the player.
|
void |
seek(long timestamp)
Seeks to timestamp position
|
void |
setAudioPlayback(IAudioPlayback audioPlayback)
Sets audio playback component
|
void |
setAudioProcessor(IAudioProcessor audioProcessor)
Sets audio processor component
|
void |
setListener(JMediaPlayer.IListener listener)
Sets listener.
|
void |
setLogger(ILogger logger)
Sets logger.
|
void |
setModel(IMediaPlayerModel model)
Sets model.
|
void |
setPlaybackSkew(long skew)
Sets playback audio/video skew (in milliseconds).
|
void |
setPlaybackSpeed(float speed)
Sets playback speed.
|
protected static void |
sleep(long millis)
Sleeps
millis milliseconds. |
boolean |
startPlayback()
Starts the playback.
|
boolean |
stopPlayback()
Stops the playback.
|
public static final java.lang.String EVENT_REMOTE_CONNECTING
EVENT_REMOTE_CONNECTING
public static final java.lang.String EVENT_REMOTE_CONNECTED
EVENT_REMOTE_CONNECTING
public static final java.lang.String EVENT_REMOTE_OPEN_FAILURE
EVENT_REMOTE_OPEN_FAILURE
public static final java.lang.String EVENT_REMOTE_OPEN_SUCCESS
EVENT_REMOTE_OPEN_SUCCESS
public static final java.lang.String EVENT_REMOTE_CLOSE
EVENT_REMOTE_CLOSE
protected static final JMediaPlayer.IListener EMPTY_LISTENER
protected JMediaPlayer.IListener listener
protected IAudioPlayback audioPlayback
protected ILogger logger
protected IAudioProcessor audioProcessor
public static JMediaPlayer create(IMediaPlayerModel model)
JMediaPlayer
.model
- JMediaPlayer
instancepublic static JMediaPlayer create(boolean live, IMediaPlayerModel model)
JMediaPlayer
.live
- true
for live streammodel
- JMediaPlayer
instancepublic IMediaPlayerModel getModel()
public void setModel(IMediaPlayerModel model)
model
- public boolean isLive()
true
for the live stream; false
for the recorded streampublic boolean isRemote()
true
for the remote stream; false
for the local streampublic void setAudioPlayback(IAudioPlayback audioPlayback)
audioPlayback
- audio playbackpublic void setAudioProcessor(IAudioProcessor audioProcessor)
audioProcessor
- audio processorpublic long getPlaybackSkew()
public void setPlaybackSkew(long skew)
skew
- public float getPlaybackSpeed()
public void setPlaybackSpeed(float speed)
speed
- public void setListener(JMediaPlayer.IListener listener)
listener
- public void setLogger(ILogger logger)
logger
- public boolean startPlayback()
true
if playback is started; otherwise false
if
playing already or playback can't be startedpublic boolean isPaused()
true
if paused; otherwise false
public boolean isPlaying()
true
if playing; otherwise false
public void pause(boolean pause)
pause
- true
to pause, false
to resumepublic void seek(long timestamp)
timestamp
- new timestamp positionpublic boolean stopPlayback()
true
if playback is stopped; otherwise false
if stopped alreadyprotected final void logModelExecutionException(java.lang.String method, java.lang.Exception e, java.lang.Object... args)
method
- e
- args
- protected static boolean isZeroOffset(int[] offset)
offset
- true
if all offsets are zero; otherwise false
protected static void sleep(long millis)
millis
milliseconds.millis
-