Class IjkMediaPlayer

    • Field Detail

      • PROP_FLOAT_VIDEO_DECODE_FRAMES_PER_SECOND

        public static final int PROP_FLOAT_VIDEO_DECODE_FRAMES_PER_SECOND
        See Also:
        Constant Field Values
      • PROP_FLOAT_VIDEO_OUTPUT_FRAMES_PER_SECOND

        public static final int PROP_FLOAT_VIDEO_OUTPUT_FRAMES_PER_SECOND
        See Also:
        Constant Field Values
      • FFP_PROP_FLOAT_PLAYBACK_RATE

        public static final int FFP_PROP_FLOAT_PLAYBACK_RATE
        See Also:
        Constant Field Values
      • FFP_PROP_FLOAT_DROP_FRAME_RATE

        public static final int FFP_PROP_FLOAT_DROP_FRAME_RATE
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_SELECTED_VIDEO_STREAM

        public static final int FFP_PROP_INT64_SELECTED_VIDEO_STREAM
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_SELECTED_AUDIO_STREAM

        public static final int FFP_PROP_INT64_SELECTED_AUDIO_STREAM
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_SELECTED_TIMEDTEXT_STREAM

        public static final int FFP_PROP_INT64_SELECTED_TIMEDTEXT_STREAM
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_VIDEO_DECODER

        public static final int FFP_PROP_INT64_VIDEO_DECODER
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_AUDIO_DECODER

        public static final int FFP_PROP_INT64_AUDIO_DECODER
        See Also:
        Constant Field Values
      • FFP_PROPV_DECODER_UNKNOWN

        public static final int FFP_PROPV_DECODER_UNKNOWN
        See Also:
        Constant Field Values
      • FFP_PROPV_DECODER_AVCODEC

        public static final int FFP_PROPV_DECODER_AVCODEC
        See Also:
        Constant Field Values
      • FFP_PROPV_DECODER_MEDIACODEC

        public static final int FFP_PROPV_DECODER_MEDIACODEC
        See Also:
        Constant Field Values
      • FFP_PROPV_DECODER_VIDEOTOOLBOX

        public static final int FFP_PROPV_DECODER_VIDEOTOOLBOX
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_VIDEO_CACHED_DURATION

        public static final int FFP_PROP_INT64_VIDEO_CACHED_DURATION
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_AUDIO_CACHED_DURATION

        public static final int FFP_PROP_INT64_AUDIO_CACHED_DURATION
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_VIDEO_CACHED_BYTES

        public static final int FFP_PROP_INT64_VIDEO_CACHED_BYTES
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_AUDIO_CACHED_BYTES

        public static final int FFP_PROP_INT64_AUDIO_CACHED_BYTES
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_VIDEO_CACHED_PACKETS

        public static final int FFP_PROP_INT64_VIDEO_CACHED_PACKETS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_AUDIO_CACHED_PACKETS

        public static final int FFP_PROP_INT64_AUDIO_CACHED_PACKETS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_ASYNC_STATISTIC_BUF_BACKWARDS

        public static final int FFP_PROP_INT64_ASYNC_STATISTIC_BUF_BACKWARDS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_ASYNC_STATISTIC_BUF_FORWARDS

        public static final int FFP_PROP_INT64_ASYNC_STATISTIC_BUF_FORWARDS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_ASYNC_STATISTIC_BUF_CAPACITY

        public static final int FFP_PROP_INT64_ASYNC_STATISTIC_BUF_CAPACITY
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_TRAFFIC_STATISTIC_BYTE_COUNT

        public static final int FFP_PROP_INT64_TRAFFIC_STATISTIC_BYTE_COUNT
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_CACHE_STATISTIC_PHYSICAL_POS

        public static final int FFP_PROP_INT64_CACHE_STATISTIC_PHYSICAL_POS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_CACHE_STATISTIC_FILE_FORWARDS

        public static final int FFP_PROP_INT64_CACHE_STATISTIC_FILE_FORWARDS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_CACHE_STATISTIC_FILE_POS

        public static final int FFP_PROP_INT64_CACHE_STATISTIC_FILE_POS
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_CACHE_STATISTIC_COUNT_BYTES

        public static final int FFP_PROP_INT64_CACHE_STATISTIC_COUNT_BYTES
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_LOGICAL_FILE_SIZE

        public static final int FFP_PROP_INT64_LOGICAL_FILE_SIZE
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_SHARE_CACHE_DATA

        public static final int FFP_PROP_INT64_SHARE_CACHE_DATA
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_BIT_RATE

        public static final int FFP_PROP_INT64_BIT_RATE
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_TCP_SPEED

        public static final int FFP_PROP_INT64_TCP_SPEED
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_LATEST_SEEK_LOAD_DURATION

        public static final int FFP_PROP_INT64_LATEST_SEEK_LOAD_DURATION
        See Also:
        Constant Field Values
      • FFP_PROP_INT64_IMMEDIATE_RECONNECT

        public static final int FFP_PROP_INT64_IMMEDIATE_RECONNECT
        See Also:
        Constant Field Values
    • Constructor Detail

      • IjkMediaPlayer

        public IjkMediaPlayer()
        Default constructor. Consider using one of the create() methods for synchronously instantiating a IjkMediaPlayer from a Uri or resource.

        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.

      • IjkMediaPlayer

        public IjkMediaPlayer​(IjkLibLoader libLoader)
        do not loadLibaray
        Parameters:
        libLoader - custom library loader, can be null.
    • Method Detail

      • loadLibrariesOnce

        public static void loadLibrariesOnce​(IjkLibLoader libLoader)
      • setDisplay

        public void setDisplay​(android.view.SurfaceHolder sh)
        Sets the 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.
        Parameters:
        sh - the SurfaceHolder to use for video display
      • setSurface

        public void setSurface​(android.view.Surface surface)
        Sets the 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.
        Parameters:
        surface - The Surface to be used for the video portion of the media.
      • setDataSource

        public void setDataSource​(android.content.Context context,
                                  android.net.Uri uri)
                           throws java.io.IOException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.SecurityException,
                                  java.lang.IllegalStateException
        Sets the data source as a content Uri.
        Parameters:
        context - the Context to use when resolving the Uri
        uri - the Content URI of the data you want to play
        Throws:
        java.lang.IllegalStateException - if it is called in an invalid state
        java.io.IOException
        java.lang.IllegalArgumentException
        java.lang.SecurityException
      • setDataSource

        public 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
        Sets the data source as a content Uri.
        Parameters:
        context - the Context to use when resolving the Uri
        uri - the Content URI of the data you want to play
        headers - 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.
        Throws:
        java.lang.IllegalStateException - if it is called in an invalid state
        java.io.IOException
        java.lang.IllegalArgumentException
        java.lang.SecurityException
      • setDataSource

        public void setDataSource​(java.lang.String path)
                           throws java.io.IOException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.SecurityException,
                                  java.lang.IllegalStateException
        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 play
        Throws:
        java.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.IOException
        java.lang.IllegalArgumentException
        java.lang.SecurityException
      • setDataSource

        public 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
        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 play
        headers - the headers associated with the http request for the stream you want to play
        Throws:
        java.lang.IllegalStateException - if it is called in an invalid state
        java.io.IOException
        java.lang.IllegalArgumentException
        java.lang.SecurityException
      • setDataSource

        public void setDataSource​(java.io.FileDescriptor fd)
                           throws java.io.IOException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.IllegalStateException
        Sets the data source (FileDescriptor) to use. It is the caller's responsibility to 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
        Throws:
        java.lang.IllegalStateException - if it is called in an invalid state
        java.io.IOException
        java.lang.IllegalArgumentException
      • setDataSource

        public void setDataSource​(IMediaDataSource mediaDataSource)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.SecurityException,
                                  java.lang.IllegalStateException
        Specified by:
        setDataSource in interface IMediaPlayer
        Overrides:
        setDataSource in class AbstractMediaPlayer
        Throws:
        java.lang.IllegalArgumentException
        java.lang.SecurityException
        java.lang.IllegalStateException
      • setAndroidIOCallback

        public void setAndroidIOCallback​(IAndroidIO androidIO)
                                  throws java.lang.IllegalArgumentException,
                                         java.lang.SecurityException,
                                         java.lang.IllegalStateException
        Throws:
        java.lang.IllegalArgumentException
        java.lang.SecurityException
        java.lang.IllegalStateException
      • getDataSource

        public java.lang.String getDataSource()
      • prepareAsync

        public void prepareAsync()
                          throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • _prepareAsync

        public void _prepareAsync()
                           throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • start

        public void start()
                   throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • stop

        public void stop()
                  throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • pause

        public void pause()
                   throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • setWakeMode

        public void setWakeMode​(android.content.Context context,
                                int mode)
      • setScreenOnWhilePlaying

        public void setScreenOnWhilePlaying​(boolean screenOn)
      • getSelectedTrack

        public int getSelectedTrack​(int trackType)
      • selectTrack

        public void selectTrack​(int track)
      • deselectTrack

        public void deselectTrack​(int track)
      • getVideoWidth

        public int getVideoWidth()
      • getVideoHeight

        public int getVideoHeight()
      • getVideoSarNum

        public int getVideoSarNum()
      • getVideoSarDen

        public int getVideoSarDen()
      • isPlaying

        public boolean isPlaying()
      • seekTo

        public void seekTo​(long msec)
                    throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException
      • getCurrentPosition

        public long getCurrentPosition()
      • getDuration

        public long getDuration()
      • release

        public void release()
        Releases resources associated with this IjkMediaPlayer object. It is considered good practice to call this method when you're done using the IjkMediaPlayer. In particular, whenever an Activity of an application is paused (its onPause() method is called), or stopped (its onStop() method is called), this method should be invoked to release the IjkMediaPlayer object, unless the application has a special need to keep the object around. In addition to unnecessary resources (such as memory and instances of codecs) being held, failure to call this method immediately if a IjkMediaPlayer object is no longer needed may also lead to continuous battery consumption for mobile devices, and playback failure for other applications if no multiple instances of the same codec are supported on a device. Even if multiple instances of the same codec are supported, some performance degradation may be expected when unnecessary multiple instances are used at the same time.
      • reset

        public void reset()
      • setLooping

        public void setLooping​(boolean looping)
        Sets the player to be looping or non-looping.
        Parameters:
        looping - whether to loop or not
      • isLooping

        public boolean isLooping()
        Checks whether the MediaPlayer is looping or non-looping.
        Returns:
        true if the MediaPlayer is currently looping, false otherwise
      • setSpeed

        public void setSpeed​(float speed)
      • getSpeed

        public float getSpeed​(float speed)
      • getVideoDecoder

        public int getVideoDecoder()
      • getVideoOutputFramesPerSecond

        public float getVideoOutputFramesPerSecond()
      • getVideoDecodeFramesPerSecond

        public float getVideoDecodeFramesPerSecond()
      • getVideoCachedDuration

        public long getVideoCachedDuration()
      • getAudioCachedDuration

        public long getAudioCachedDuration()
      • getVideoCachedBytes

        public long getVideoCachedBytes()
      • getAudioCachedBytes

        public long getAudioCachedBytes()
      • getVideoCachedPackets

        public long getVideoCachedPackets()
      • getAudioCachedPackets

        public long getAudioCachedPackets()
      • getAsyncStatisticBufBackwards

        public long getAsyncStatisticBufBackwards()
      • getAsyncStatisticBufForwards

        public long getAsyncStatisticBufForwards()
      • getAsyncStatisticBufCapacity

        public long getAsyncStatisticBufCapacity()
      • getTrafficStatisticByteCount

        public long getTrafficStatisticByteCount()
      • getCacheStatisticPhysicalPos

        public long getCacheStatisticPhysicalPos()
      • getCacheStatisticFileForwards

        public long getCacheStatisticFileForwards()
      • getCacheStatisticFilePos

        public long getCacheStatisticFilePos()
      • getCacheStatisticCountBytes

        public long getCacheStatisticCountBytes()
      • getFileSize

        public long getFileSize()
      • getBitRate

        public long getBitRate()
      • getTcpSpeed

        public long getTcpSpeed()
      • getSeekLoadDuration

        public long getSeekLoadDuration()
      • getDropFrameRate

        public float getDropFrameRate()
      • setVolume

        public void setVolume​(float leftVolume,
                              float rightVolume)
      • getAudioSessionId

        public int getAudioSessionId()
      • getMediaInfo

        public MediaInfo getMediaInfo()
      • setLogEnabled

        public void setLogEnabled​(boolean enable)
      • isPlayable

        public boolean isPlayable()
      • setOption

        public void setOption​(int category,
                              java.lang.String name,
                              java.lang.String value)
      • setOption

        public void setOption​(int category,
                              java.lang.String name,
                              long value)
      • getMediaMeta

        public android.os.Bundle getMediaMeta()
      • getColorFormatName

        public static java.lang.String getColorFormatName​(int mediaCodecColorFormat)
      • setAudioStreamType

        public void setAudioStreamType​(int streamtype)
      • setKeepInBackground

        public void setKeepInBackground​(boolean keepInBackground)
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • httphookReconnect

        public void httphookReconnect()
      • setCacheShare

        public void setCacheShare​(int share)
      • native_profileBegin

        public static void native_profileBegin​(java.lang.String libName)
      • native_profileEnd

        public static void native_profileEnd()
      • native_setLogLevel

        public static void native_setLogLevel​(int level)