public final class IjkMediaPlayer extends AbstractMediaPlayer
| Modifier and Type | Class and Description |
|---|---|
static class |
IjkMediaPlayer.DefaultMediaCodecSelector |
static interface |
IjkMediaPlayer.OnControlMessageListener |
static interface |
IjkMediaPlayer.OnMediaCodecSelectListener |
static interface |
IjkMediaPlayer.OnNativeInvokeListener |
IMediaPlayer.OnBufferingUpdateListener, IMediaPlayer.OnCompletionListener, IMediaPlayer.OnErrorListener, IMediaPlayer.OnInfoListener, IMediaPlayer.OnPreparedListener, IMediaPlayer.OnSeekCompleteListener, IMediaPlayer.OnTimedTextListener, IMediaPlayer.OnVideoSizeChangedListenerMEDIA_ERROR_IO, MEDIA_ERROR_MALFORMED, MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK, MEDIA_ERROR_SERVER_DIED, MEDIA_ERROR_TIMED_OUT, MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_UNSUPPORTED, MEDIA_INFO_AUDIO_DECODED_START, MEDIA_INFO_AUDIO_RENDERING_START, MEDIA_INFO_AUDIO_SEEK_RENDERING_START, MEDIA_INFO_BAD_INTERLEAVING, MEDIA_INFO_BUFFERING_END, MEDIA_INFO_BUFFERING_START, MEDIA_INFO_COMPONENT_OPEN, MEDIA_INFO_FIND_STREAM_INFO, MEDIA_INFO_MEDIA_ACCURATE_SEEK_COMPLETE, MEDIA_INFO_METADATA_UPDATE, MEDIA_INFO_NETWORK_BANDWIDTH, MEDIA_INFO_NOT_SEEKABLE, MEDIA_INFO_OPEN_INPUT, MEDIA_INFO_STARTED_AS_NEXT, MEDIA_INFO_SUBTITLE_TIMED_OUT, MEDIA_INFO_TIMED_TEXT_ERROR, MEDIA_INFO_UNKNOWN, MEDIA_INFO_UNSUPPORTED_SUBTITLE, MEDIA_INFO_VIDEO_DECODED_START, MEDIA_INFO_VIDEO_RENDERING_START, MEDIA_INFO_VIDEO_ROTATION_CHANGED, MEDIA_INFO_VIDEO_SEEK_RENDERING_START, MEDIA_INFO_VIDEO_TRACK_LAGGING| Constructor and Description |
|---|
IjkMediaPlayer()
Default constructor.
|
IjkMediaPlayer(IjkLibLoader libLoader)
do not loadLibaray
|
| Modifier and Type | Method and Description |
|---|---|
void |
_prepareAsync() |
void |
deselectTrack(int track) |
protected void |
finalize() |
long |
getAsyncStatisticBufBackwards() |
long |
getAsyncStatisticBufCapacity() |
long |
getAsyncStatisticBufForwards() |
long |
getAudioCachedBytes() |
long |
getAudioCachedDuration() |
long |
getAudioCachedPackets() |
int |
getAudioSessionId() |
long |
getBitRate() |
long |
getCacheStatisticCountBytes() |
long |
getCacheStatisticFileForwards() |
long |
getCacheStatisticFilePos() |
long |
getCacheStatisticPhysicalPos() |
static java.lang.String |
getColorFormatName(int mediaCodecColorFormat) |
long |
getCurrentPosition() |
java.lang.String |
getDataSource() |
float |
getDropFrameRate() |
long |
getDuration() |
long |
getFileSize() |
MediaInfo |
getMediaInfo() |
android.os.Bundle |
getMediaMeta() |
long |
getSeekLoadDuration() |
int |
getSelectedTrack(int trackType) |
float |
getSpeed(float speed) |
long |
getTcpSpeed() |
IjkTrackInfo[] |
getTrackInfo() |
long |
getTrafficStatisticByteCount() |
long |
getVideoCachedBytes() |
long |
getVideoCachedDuration() |
long |
getVideoCachedPackets() |
float |
getVideoDecodeFramesPerSecond() |
int |
getVideoDecoder() |
int |
getVideoHeight() |
float |
getVideoOutputFramesPerSecond() |
int |
getVideoSarDen() |
int |
getVideoSarNum() |
int |
getVideoWidth() |
void |
httphookReconnect() |
boolean |
isLooping()
Checks whether the MediaPlayer is looping or non-looping.
|
boolean |
isPlayable() |
boolean |
isPlaying() |
static void |
loadLibrariesOnce(IjkLibLoader libLoader) |
static void |
native_profileBegin(java.lang.String libName) |
static void |
native_profileEnd() |
static void |
native_setLogLevel(int level) |
void |
pause() |
void |
prepareAsync() |
void |
release()
Releases resources associated with this IjkMediaPlayer object.
|
void |
reset() |
void |
resetListeners() |
void |
seekTo(long msec) |
void |
selectTrack(int track) |
void |
setAndroidIOCallback(IAndroidIO androidIO) |
void |
setAudioStreamType(int streamtype) |
void |
setCacheShare(int share) |
void |
setDataSource(android.content.Context context,
android.net.Uri uri)
Sets the data source as a content Uri.
|
void |
setDataSource(android.content.Context context,
android.net.Uri uri,
java.util.Map<java.lang.String,java.lang.String> headers)
Sets the data source as a content Uri.
|
void |
setDataSource(java.io.FileDescriptor fd)
Sets the data source (FileDescriptor) to use.
|
void |
setDataSource(IMediaDataSource mediaDataSource) |
void |
setDataSource(java.lang.String path)
Sets the data source (file-path or http/rtsp URL) to use.
|
void |
setDataSource(java.lang.String path,
java.util.Map<java.lang.String,java.lang.String> headers)
Sets the data source (file-path or http/rtsp URL) to use.
|
void |
setDisplay(android.view.SurfaceHolder sh)
Sets the
SurfaceHolder to use for displaying the video portion of
the media. |
void |
setKeepInBackground(boolean keepInBackground) |
void |
setLogEnabled(boolean enable) |
void |
setLooping(boolean looping)
Sets the player to be looping or non-looping.
|
void |
setOnControlMessageListener(IjkMediaPlayer.OnControlMessageListener listener) |
void |
setOnMediaCodecSelectListener(IjkMediaPlayer.OnMediaCodecSelectListener listener) |
void |
setOnNativeInvokeListener(IjkMediaPlayer.OnNativeInvokeListener listener) |
void |
setOption(int category,
java.lang.String name,
long value) |
void |
setOption(int category,
java.lang.String name,
java.lang.String value) |
void |
setScreenOnWhilePlaying(boolean screenOn) |
void |
setSpeed(float speed) |
void |
setSurface(android.view.Surface surface)
Sets the
Surface to be used as the sink for the video portion of
the media. |
void |
setVolume(float leftVolume,
float rightVolume) |
void |
setWakeMode(android.content.Context context,
int mode) |
void |
start() |
void |
stop() |
notifyOnBufferingUpdate, notifyOnCompletion, notifyOnError, notifyOnInfo, notifyOnPrepared, notifyOnSeekComplete, notifyOnTimedText, notifyOnVideoSizeChanged, setOnBufferingUpdateListener, setOnCompletionListener, setOnErrorListener, setOnInfoListener, setOnPreparedListener, setOnSeekCompleteListener, setOnTimedTextListener, setOnVideoSizeChangedListenerprotected static final int MEDIA_SET_VIDEO_SAR
public static final int IJK_LOG_UNKNOWN
public static final int IJK_LOG_DEFAULT
public static final int IJK_LOG_VERBOSE
public static final int IJK_LOG_DEBUG
public static final int IJK_LOG_INFO
public static final int IJK_LOG_WARN
public static final int IJK_LOG_ERROR
public static final int IJK_LOG_FATAL
public static final int IJK_LOG_SILENT
public static final int OPT_CATEGORY_FORMAT
public static final int OPT_CATEGORY_CODEC
public static final int OPT_CATEGORY_SWS
public static final int OPT_CATEGORY_PLAYER
public static final int SDL_FCC_YV12
public static final int SDL_FCC_RV16
public static final int SDL_FCC_RV32
public static final int PROP_FLOAT_VIDEO_DECODE_FRAMES_PER_SECOND
public static final int PROP_FLOAT_VIDEO_OUTPUT_FRAMES_PER_SECOND
public static final int FFP_PROP_FLOAT_PLAYBACK_RATE
public static final int FFP_PROP_FLOAT_DROP_FRAME_RATE
public static final int FFP_PROP_INT64_SELECTED_VIDEO_STREAM
public static final int FFP_PROP_INT64_SELECTED_AUDIO_STREAM
public static final int FFP_PROP_INT64_SELECTED_TIMEDTEXT_STREAM
public static final int FFP_PROP_INT64_VIDEO_DECODER
public static final int FFP_PROP_INT64_AUDIO_DECODER
public static final int FFP_PROPV_DECODER_UNKNOWN
public static final int FFP_PROPV_DECODER_AVCODEC
public static final int FFP_PROPV_DECODER_MEDIACODEC
public static final int FFP_PROPV_DECODER_VIDEOTOOLBOX
public static final int FFP_PROP_INT64_VIDEO_CACHED_DURATION
public static final int FFP_PROP_INT64_AUDIO_CACHED_DURATION
public static final int FFP_PROP_INT64_VIDEO_CACHED_BYTES
public static final int FFP_PROP_INT64_AUDIO_CACHED_BYTES
public static final int FFP_PROP_INT64_VIDEO_CACHED_PACKETS
public static final int FFP_PROP_INT64_AUDIO_CACHED_PACKETS
public static final int FFP_PROP_INT64_ASYNC_STATISTIC_BUF_BACKWARDS
public static final int FFP_PROP_INT64_ASYNC_STATISTIC_BUF_FORWARDS
public static final int FFP_PROP_INT64_ASYNC_STATISTIC_BUF_CAPACITY
public static final int FFP_PROP_INT64_TRAFFIC_STATISTIC_BYTE_COUNT
public static final int FFP_PROP_INT64_CACHE_STATISTIC_PHYSICAL_POS
public static final int FFP_PROP_INT64_CACHE_STATISTIC_FILE_FORWARDS
public static final int FFP_PROP_INT64_CACHE_STATISTIC_FILE_POS
public static final int FFP_PROP_INT64_CACHE_STATISTIC_COUNT_BYTES
public static final int FFP_PROP_INT64_LOGICAL_FILE_SIZE
public static final int FFP_PROP_INT64_SHARE_CACHE_DATA
public static final int FFP_PROP_INT64_BIT_RATE
public static final int FFP_PROP_INT64_TCP_SPEED
public static final int FFP_PROP_INT64_LATEST_SEEK_LOAD_DURATION
public static final int FFP_PROP_INT64_IMMEDIATE_RECONNECT
public IjkMediaPlayer()
When done with the IjkMediaPlayer, you should call release(), to
free the resources. If not released, too many IjkMediaPlayer instances
may result in an exception.
public IjkMediaPlayer(IjkLibLoader libLoader)
libLoader - custom library loader, can be null.public static void loadLibrariesOnce(IjkLibLoader libLoader)
public void setDisplay(android.view.SurfaceHolder sh)
SurfaceHolder to use for displaying the video portion of
the media.
Either a surface holder or surface must be set if a display or video sink
is needed. Not calling this method or setSurface(Surface) when
playing back a video will result in only the audio track being played. A
null surface holder or surface will result in only the audio track being
played.sh - the SurfaceHolder to use for video displaypublic void setSurface(android.view.Surface surface)
Surface to be used as the sink for the video portion of
the media. This is similar to setDisplay(SurfaceHolder), but
does not support setScreenOnWhilePlaying(boolean). Setting a
Surface will un-set any Surface or SurfaceHolder that was previously set.
A null surface will result in only the audio track being played.
If the Surface sends frames to a SurfaceTexture, the timestamps
returned from SurfaceTexture.getTimestamp() will have an
unspecified zero point. These timestamps cannot be directly compared
between different media sources, different instances of the same media
source, or multiple runs of the same program. The timestamp is normally
monotonically increasing and is unaffected by time-of-day adjustments,
but it is reset when the position is set.surface - The Surface to be used for the video portion of the
media.public void setDataSource(android.content.Context context,
android.net.Uri uri)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.SecurityException,
java.lang.IllegalStateException
context - the Context to use when resolving the Uriuri - the Content URI of the data you want to playjava.lang.IllegalStateException - if it is called in an invalid statejava.io.IOExceptionjava.lang.IllegalArgumentExceptionjava.lang.SecurityExceptionpublic void setDataSource(android.content.Context context,
android.net.Uri uri,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.SecurityException,
java.lang.IllegalStateException
context - the Context to use when resolving the Uriuri - the Content URI of the data you want to playheaders - the headers to be sent together with the request for the data
Note that the cross domain redirection is allowed by default, but that can be
changed with key/value pairs through the headers parameter with
"android-allow-cross-domain-redirect" as the key and "0" or "1" as the value
to disallow or allow cross domain redirection.java.lang.IllegalStateException - if it is called in an invalid statejava.io.IOExceptionjava.lang.IllegalArgumentExceptionjava.lang.SecurityExceptionpublic void setDataSource(java.lang.String path)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.SecurityException,
java.lang.IllegalStateException
path - the path of the file, or the http/rtsp URL of the stream you
want to playjava.lang.IllegalStateException - if it is called in an invalid state
When path refers to a local file, the file may
actually be opened by a process other than the calling
application. This implies that the pathname should be an
absolute path (as any other process runs with unspecified
current working directory), and that the pathname should
reference a world-readable file.
java.io.IOExceptionjava.lang.IllegalArgumentExceptionjava.lang.SecurityExceptionpublic void setDataSource(java.lang.String path,
java.util.Map<java.lang.String,java.lang.String> headers)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.SecurityException,
java.lang.IllegalStateException
path - the path of the file, or the http/rtsp URL of the stream you want to playheaders - the headers associated with the http request for the stream you want to playjava.lang.IllegalStateException - if it is called in an invalid statejava.io.IOExceptionjava.lang.IllegalArgumentExceptionjava.lang.SecurityExceptionpublic void setDataSource(java.io.FileDescriptor fd)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.IllegalStateException
fd - the FileDescriptor for the file you want to playjava.lang.IllegalStateException - if it is called in an invalid statejava.io.IOExceptionjava.lang.IllegalArgumentExceptionpublic void setDataSource(IMediaDataSource mediaDataSource) throws java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.IllegalStateException
setDataSource in interface IMediaPlayersetDataSource in class AbstractMediaPlayerjava.lang.IllegalArgumentExceptionjava.lang.SecurityExceptionjava.lang.IllegalStateExceptionpublic void setAndroidIOCallback(IAndroidIO androidIO) throws java.lang.IllegalArgumentException, java.lang.SecurityException, java.lang.IllegalStateException
java.lang.IllegalArgumentExceptionjava.lang.SecurityExceptionjava.lang.IllegalStateExceptionpublic java.lang.String getDataSource()
public void prepareAsync()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void _prepareAsync()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void start()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void stop()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void pause()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void setWakeMode(android.content.Context context,
int mode)
public void setScreenOnWhilePlaying(boolean screenOn)
public IjkTrackInfo[] getTrackInfo()
public int getSelectedTrack(int trackType)
public void selectTrack(int track)
public void deselectTrack(int track)
public int getVideoWidth()
public int getVideoHeight()
public int getVideoSarNum()
public int getVideoSarDen()
public boolean isPlaying()
public void seekTo(long msec)
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic long getCurrentPosition()
public long getDuration()
public void release()
public void reset()
public void setLooping(boolean looping)
looping - whether to loop or notpublic boolean isLooping()
public void setSpeed(float speed)
public float getSpeed(float speed)
public int getVideoDecoder()
public float getVideoOutputFramesPerSecond()
public float getVideoDecodeFramesPerSecond()
public long getVideoCachedDuration()
public long getAudioCachedDuration()
public long getVideoCachedBytes()
public long getAudioCachedBytes()
public long getVideoCachedPackets()
public long getAudioCachedPackets()
public long getAsyncStatisticBufBackwards()
public long getAsyncStatisticBufForwards()
public long getAsyncStatisticBufCapacity()
public long getTrafficStatisticByteCount()
public long getCacheStatisticPhysicalPos()
public long getCacheStatisticFileForwards()
public long getCacheStatisticFilePos()
public long getCacheStatisticCountBytes()
public long getFileSize()
public long getBitRate()
public long getTcpSpeed()
public long getSeekLoadDuration()
public float getDropFrameRate()
public void setVolume(float leftVolume,
float rightVolume)
public int getAudioSessionId()
public MediaInfo getMediaInfo()
public void setLogEnabled(boolean enable)
public boolean isPlayable()
public void setOption(int category,
java.lang.String name,
java.lang.String value)
public void setOption(int category,
java.lang.String name,
long value)
public android.os.Bundle getMediaMeta()
public static java.lang.String getColorFormatName(int mediaCodecColorFormat)
public void setAudioStreamType(int streamtype)
public void setKeepInBackground(boolean keepInBackground)
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void httphookReconnect()
public void setCacheShare(int share)
public void setOnControlMessageListener(IjkMediaPlayer.OnControlMessageListener listener)
public void setOnNativeInvokeListener(IjkMediaPlayer.OnNativeInvokeListener listener)
public void setOnMediaCodecSelectListener(IjkMediaPlayer.OnMediaCodecSelectListener listener)
public void resetListeners()
resetListeners in class AbstractMediaPlayerpublic static void native_profileBegin(java.lang.String libName)
public static void native_profileEnd()
public static void native_setLogLevel(int level)