##.简介
IjkPlayer是Bilibili推出的一个开源播放器库,底层是基于ffmpeg来实现的,支持各种常见的拉流协议,支持软解码和硬解码,支持变速播放。很多视频平台都在使用。
官方的github地址:
GitHub - bilibili/ijkplayer: Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
开源库中封装了
IMediaPlayer接口,包括一个播放器正常需要的绝大部分功能。在开源库中为该接口提供几种实现方式,包括使用Ijkplayer方式实现和Android自带的解码方式实现,使用时可根据情况自由选择方式。
##.主要API介绍(见注释)
void setDisplay(SurfaceHolder sh);
void setDataSource(Context context, Uri uri)
throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void setDataSource(Context context, Uri uri, Map headers)
throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
void setDataSource(FileDescriptor fd)
throws IOException, IllegalArgumentException, IllegalStateException;
void setDataSource(String path)
throws IOException, IllegalArgumentException, SecurityException, IllegalStateException;
void setDataSource(IMediaDataSource mediaDataSource);
String getDataSource();
void prepareAsync() throws IllegalStateException;
void start() throws IllegalStateException;
void stop() throws IllegalStateException;
void pause() throws IllegalStateException;
void setScreenOnWhilePlaying(boolean screenOn);
@Deprecated
void setWakeMode(Context context, int mode);
int getVideoWidth();
int getVideoHeight();
boolean isPlaying();
void seekTo(long msec) throws IllegalStateException;
long getCurrentPosition();
long getDuration();
long getPlayableDuration();
void setSpeed(float speed);
void setVolume(float leftVolume, float rightVolume);
void setLooping(boolean looping);
boolean isLooping();
void reset();
void release();
int getAudioSessionId();
MediaInfo getMediaInfo();
@Deprecated
boolean isPlayable();
void setAudioStreamType(int streamtype);
@Deprecated
void setKeepInBackground(boolean keepInBackground);
int getVideoSarNum();
int getVideoSarDen();
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void setSurface(Surface surface);
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
ITrackInfo[] getTrackInfo();
void setOnPreparedListener(OnPreparedListener listener);
void setOnCompletionListener(OnCompletionListener listener);
void setOnBufferingUpdateListener(
OnBufferingUpdateListener listener);
void setOnSeekCompleteListener(
OnSeekCompleteListener listener);
void setOnVideoSizeChangedListener(
OnVideoSizeChangedListener listener);
void setOnErrorListener(OnErrorListener listener);
void setOnInfoListener(OnInfoListener listener);
void setOnTimedTextListener(OnTimedTextListener listener);