-
- All Implemented Interfaces:
-
tv.danmaku.ijk.media.player.IMediaPlayer
public final class IjkMediaPlayer extends AbstractMediaPlayer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceIjkMediaPlayer.OnControlMessageListenerpublic interfaceIjkMediaPlayer.OnNativeInvokeListenerpublic interfaceIjkMediaPlayer.OnMediaCodecSelectListenerpublic classIjkMediaPlayer.DefaultMediaCodecSelector
-
Field Summary
-
Constructor Summary
Constructors Constructor Description IjkMediaPlayer()Default constructor. IjkMediaPlayer(IjkLibLoader libLoader)do not loadLibaray
-
Method Summary
Modifier and Type Method Description static voidloadLibrariesOnce(IjkLibLoader libLoader)voidsetDisplay(SurfaceHolder sh)Sets the SurfaceHolder to use for displaying the video portion ofthe media.Either a surface holder or surface must be set if a display or video sinkis needed. voidsetSurface(Surface surface)Sets the Surface to be used as the sink for the video portion ofthe media. voidsetDataSource(Context context, Uri uri)Sets the data source as a content Uri. voidsetDataSource(Context context, Uri uri, Map<String, String> headers)Sets the data source as a content Uri. voidsetDataSource(String path)Sets the data source (file-path or http/rtsp URL) to use. voidsetDataSource(String path, Map<String, String> headers)Sets the data source (file-path or http/rtsp URL) to use. voidsetDataSource(FileDescriptor fd)Sets the data source (FileDescriptor) to use. voidsetDataSource(IMediaDataSource mediaDataSource)voidsetAndroidIOCallback(IAndroidIO androidIO)StringgetDataSource()voidprepareAsync()native void_prepareAsync()voidstart()voidstop()voidpause()voidsetWakeMode(Context context, int mode)voidsetScreenOnWhilePlaying(boolean screenOn)Array<IjkTrackInfo>getTrackInfo()intgetSelectedTrack(int trackType)voidselectTrack(int track)voiddeselectTrack(int track)intgetVideoWidth()intgetVideoHeight()intgetVideoSarNum()intgetVideoSarDen()native booleanisPlaying()native voidseekTo(long msec)native longgetCurrentPosition()native longgetDuration()voidrelease()Releases resources associated with this IjkMediaPlayer object. voidreset()voidsetLooping(boolean looping)Sets the player to be looping or non-looping. booleanisLooping()Checks whether the MediaPlayer is looping or non-looping. voidsetSpeed(float speed)floatgetSpeed(float speed)intgetVideoDecoder()floatgetVideoOutputFramesPerSecond()floatgetVideoDecodeFramesPerSecond()longgetVideoCachedDuration()longgetAudioCachedDuration()longgetVideoCachedBytes()longgetAudioCachedBytes()longgetVideoCachedPackets()longgetAudioCachedPackets()longgetAsyncStatisticBufBackwards()longgetAsyncStatisticBufForwards()longgetAsyncStatisticBufCapacity()longgetTrafficStatisticByteCount()longgetCacheStatisticPhysicalPos()longgetCacheStatisticFileForwards()longgetCacheStatisticFilePos()longgetCacheStatisticCountBytes()longgetFileSize()longgetBitRate()longgetTcpSpeed()longgetSeekLoadDuration()floatgetDropFrameRate()native voidsetVolume(float leftVolume, float rightVolume)native intgetAudioSessionId()MediaInfogetMediaInfo()voidsetLogEnabled(boolean enable)booleanisPlayable()voidsetOption(int category, String name, String value)voidsetOption(int category, String name, long value)BundlegetMediaMeta()static StringgetColorFormatName(int mediaCodecColorFormat)voidsetAudioStreamType(int streamtype)voidsetKeepInBackground(boolean keepInBackground)voidhttphookReconnect()voidsetCacheShare(int share)voidsetOnControlMessageListener(IjkMediaPlayer.OnControlMessageListener listener)voidsetOnNativeInvokeListener(IjkMediaPlayer.OnNativeInvokeListener listener)voidsetOnMediaCodecSelectListener(IjkMediaPlayer.OnMediaCodecSelectListener listener)voidresetListeners()static native voidnative_profileBegin(String libName)static native voidnative_profileEnd()static native voidnative_setLogLevel(int level)-
Methods inherited from class tv.danmaku.ijk.media.player.AbstractMediaPlayer
setOnBufferingUpdateListener, setOnCompletionListener, setOnErrorListener, setOnInfoListener, setOnPreparedListener, setOnSeekCompleteListener, setOnTimedTextListener, setOnVideoSizeChangedListener -
Methods inherited from class tv.danmaku.ijk.media.player.IMediaPlayer
getTrackInfo, setOnSeekCompleteListener -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
IjkMediaPlayer
IjkMediaPlayer()
Default constructor.
-
IjkMediaPlayer
IjkMediaPlayer(IjkLibLoader libLoader)
do not loadLibaray- Parameters:
libLoader- custom library loader, can be null.
-
-
Method Detail
-
loadLibrariesOnce
static void loadLibrariesOnce(IjkLibLoader libLoader)
-
setDisplay
void setDisplay(SurfaceHolder sh)
Sets the SurfaceHolder to use for displaying the video portion ofthe media.Either a surface holder or surface must be set if a display or video sinkis needed. Not calling this method or setSurface whenplaying back a video will result in only the audio track being played. Anull surface holder or surface will result in only the audio track beingplayed.
- Parameters:
sh- the SurfaceHolder to use for video display
-
setSurface
void setSurface(Surface surface)
Sets the Surface to be used as the sink for the video portion ofthe media. This is similar to setDisplay, butdoes not support setScreenOnWhilePlaying. Setting aSurface 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 timestampsreturned from getTimestamp will have anunspecified zero point. These timestamps cannot be directly comparedbetween different media sources, different instances of the same mediasource, or multiple runs of the same program. The timestamp is normallymonotonically increasing and is unaffected by time-of-day adjustments,but it is reset when the position is set.
- Parameters:
surface- The Surface to be used for the video portion of themedia.
-
setDataSource
void setDataSource(Context context, Uri uri)
Sets the data source as a content Uri.
- Parameters:
context- the Context to use when resolving the Uriuri- the Content URI of the data you want to play
-
setDataSource
void setDataSource(Context context, Uri uri, Map<String, String> headers)
Sets the data source as a content Uri.
- Parameters:
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 dataNote that the cross domain redirection is allowed by default, but that can bechanged with key/value pairs through the headers parameter with"android-allow-cross-domain-redirect" as the key and "0" or "1" as the valueto disallow or allow cross domain redirection.
-
setDataSource
void setDataSource(String path)
Sets the data source (file-path or http/rtsp URL) to use.
- Parameters:
path- the path of the file, or the http/rtsp URL of the stream youwant to play
-
setDataSource
void setDataSource(String path, Map<String, String> headers)
Sets the data source (file-path or http/rtsp URL) to use.
- Parameters:
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 play
-
setDataSource
void setDataSource(FileDescriptor fd)
Sets the data source (FileDescriptor) to use. It is the caller's responsibilityto close the file descriptor. It is safe to do so as soon as this call returns.
- Parameters:
fd- the FileDescriptor for the file you want to play
-
setDataSource
void setDataSource(IMediaDataSource mediaDataSource)
-
setAndroidIOCallback
void setAndroidIOCallback(IAndroidIO androidIO)
-
getDataSource
String getDataSource()
-
prepareAsync
void prepareAsync()
-
_prepareAsync
native void _prepareAsync()
-
start
void start()
-
stop
void stop()
-
pause
void pause()
-
setWakeMode
void setWakeMode(Context context, int mode)
-
setScreenOnWhilePlaying
void setScreenOnWhilePlaying(boolean screenOn)
-
getTrackInfo
Array<IjkTrackInfo> getTrackInfo()
-
getSelectedTrack
int getSelectedTrack(int trackType)
-
selectTrack
void selectTrack(int track)
-
deselectTrack
void deselectTrack(int track)
-
getVideoWidth
int getVideoWidth()
-
getVideoHeight
int getVideoHeight()
-
getVideoSarNum
int getVideoSarNum()
-
getVideoSarDen
int getVideoSarDen()
-
isPlaying
native boolean isPlaying()
-
seekTo
native void seekTo(long msec)
-
getCurrentPosition
native long getCurrentPosition()
-
getDuration
native long getDuration()
-
release
void release()
Releases resources associated with this IjkMediaPlayer object. It isconsidered good practice to call this method when you're done using theIjkMediaPlayer. In particular, whenever an Activity of an application ispaused (its onPause() method is called), or stopped (its onStop() methodis called), this method should be invoked to release the IjkMediaPlayerobject, unless the application has a special need to keep the objectaround. In addition to unnecessary resources (such as memory andinstances of codecs) being held, failure to call this method immediatelyif a IjkMediaPlayer object is no longer needed may also lead tocontinuous battery consumption for mobile devices, and playback failurefor other applications if no multiple instances of the same codec aresupported on a device. Even if multiple instances of the same codec aresupported, some performance degradation may be expected when unnecessarymultiple instances are used at the same time.
-
reset
void reset()
-
setLooping
void setLooping(boolean looping)
Sets the player to be looping or non-looping.
- Parameters:
looping- whether to loop or not
-
isLooping
boolean isLooping()
Checks whether the MediaPlayer is looping or non-looping.
-
setSpeed
void setSpeed(float speed)
-
getSpeed
float getSpeed(float speed)
-
getVideoDecoder
int getVideoDecoder()
-
getVideoOutputFramesPerSecond
float getVideoOutputFramesPerSecond()
-
getVideoDecodeFramesPerSecond
float getVideoDecodeFramesPerSecond()
-
getVideoCachedDuration
long getVideoCachedDuration()
-
getAudioCachedDuration
long getAudioCachedDuration()
-
getVideoCachedBytes
long getVideoCachedBytes()
-
getAudioCachedBytes
long getAudioCachedBytes()
-
getVideoCachedPackets
long getVideoCachedPackets()
-
getAudioCachedPackets
long getAudioCachedPackets()
-
getAsyncStatisticBufBackwards
long getAsyncStatisticBufBackwards()
-
getAsyncStatisticBufForwards
long getAsyncStatisticBufForwards()
-
getAsyncStatisticBufCapacity
long getAsyncStatisticBufCapacity()
-
getTrafficStatisticByteCount
long getTrafficStatisticByteCount()
-
getCacheStatisticPhysicalPos
long getCacheStatisticPhysicalPos()
-
getCacheStatisticFileForwards
long getCacheStatisticFileForwards()
-
getCacheStatisticFilePos
long getCacheStatisticFilePos()
-
getCacheStatisticCountBytes
long getCacheStatisticCountBytes()
-
getFileSize
long getFileSize()
-
getBitRate
long getBitRate()
-
getTcpSpeed
long getTcpSpeed()
-
getSeekLoadDuration
long getSeekLoadDuration()
-
getDropFrameRate
float getDropFrameRate()
-
setVolume
native void setVolume(float leftVolume, float rightVolume)
-
getAudioSessionId
native int getAudioSessionId()
-
getMediaInfo
MediaInfo getMediaInfo()
-
setLogEnabled
void setLogEnabled(boolean enable)
-
isPlayable
boolean isPlayable()
-
getMediaMeta
Bundle getMediaMeta()
-
getColorFormatName
static String getColorFormatName(int mediaCodecColorFormat)
-
setAudioStreamType
void setAudioStreamType(int streamtype)
-
setKeepInBackground
void setKeepInBackground(boolean keepInBackground)
-
httphookReconnect
void httphookReconnect()
-
setCacheShare
void setCacheShare(int share)
-
setOnControlMessageListener
void setOnControlMessageListener(IjkMediaPlayer.OnControlMessageListener listener)
-
setOnNativeInvokeListener
void setOnNativeInvokeListener(IjkMediaPlayer.OnNativeInvokeListener listener)
-
setOnMediaCodecSelectListener
void setOnMediaCodecSelectListener(IjkMediaPlayer.OnMediaCodecSelectListener listener)
-
resetListeners
void resetListeners()
-
native_profileBegin
static native void native_profileBegin(String libName)
-
native_profileEnd
static native void native_profileEnd()
-
native_setLogLevel
static native void native_setLogLevel(int level)
-
-
-
-