PLDroidPlayer 是为 pili 流媒体云服务提供的一套播放直播流的 SDK,旨在解决快速、轻松实现 Android 设备播放直播流,便于 pili 流媒体云服务的开发者专注于产品业务本身,而不必在技术细节上花费不必要的时间。
- 基于 ijkplayer ( based on ffplay )
- Android Min API 9
- 支持 RTMP, HLS 协议
- 支持 ARMv7a
- 支持 MediaCodec 硬解码
- 提供
VideoView
控件 - 可定制化的
MediaController
- 支持
seekTo()
- 支持获取当前播放时长
getDuration()
- 支持获取当前播放的位置
getCurrentPosition()
- 支持音量控制
setVolume()
- 提供如下接口:
OnPreparedListener
OnCompletionListener
OnErrorListener
OnInfoListener
- | ijkplayer | PLDroidPlayer |
---|---|---|
Shared Library Size | 较大 | 较小 |
Shared Library Count | 5个 | 1个 |
Widget | 有商业授权风险 | 无商业授权风险 |
MediaController | 难以定制化 | 容易定制化 |
从 releases/
目录获取:
- pldroid-player-xxx.jar
- ijkmediaplayer-xxx.jar
- armeabi-v7a/libpldroidplayer.so
并在项目中加入对应的 jar/so 文件的依赖关系。可参考 PLDroidPlayerDemo 中的做法。
1 初始化 VideoView 及其布局
<com.pili.pldroid.player.widget.VideoView
android:id="@+id/video_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" />
mVideoView = (VideoView) findViewById(R.id.video_view);
2 VideoView 与 MediaController 建立联系
mMediaController.setMediaPlayer(mVideoView);
mVideoView.setMediaController(mMediaController);
3 传入播放地址,可以是 /path/to/local.mp4
本地文件绝对路径,或 HLS URL,或 RTMP URL
mVideoView.setVideoPath(mVideoPath);
4 设置 Listener
public class VideoPlayerActivity extends Activity implements
OnCompletionListener,
OnInfoListener,
OnErrorListener,
OnPreparedListener {
...
mVideoView.setOnErrorListener(this);
mVideoView.setOnCompletionListener(this);
mVideoView.setOnInfoListener(this);
mVideoView.setOnPreparedListener(this);
...
@Override
public void onCompletion(IMediaPlayer mp) {
...
}
@Override
public boolean onError(IMediaPlayer mp, int what, int extra) {
...
}
@Override
public boolean onInfo(IMediaPlayer mp, int what, int extra) {
...
}
@Override
public void onPrepared(IMediaPlayer mp) {
...
}
- ffmpeg
- libyuv
- sdl
- libVLC
- 1.0.0 (Release Notes)
发布 PLDroidPlayer v1.0.0