out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Out of the box android video player base on ijkplayer 0.8.8 (for flutter please visit GPlayer)
this project is total refactor of GiraffePlayer to support in ListView/RecyclerView and improve the performance,all player tasks do in worker thread.
//step 1: add jcenter repositories in your root poject build file
repositories {
...
jcenter()
}
//step 2: add dependency,there are 3 type of aar,see the flow table
api 'com.github.tcking:giraffeplayer2:0.1.25-lazyLoad'
| aar type | aar size | decoders | support abi |
|---|---|---|---|
api 'com.github.tcking:giraffeplayer2:0.1.25' |
2.2M | common decoders | default armeabi,can add manually |
api 'com.github.tcking:giraffeplayer2:0.1.25-lazyLoad' |
180K | all decoders | download player(so files) on demand by device abi |
api 'com.github.tcking:giraffeplayer2:0.1.25-full' |
5.4M | all decoders | default armeabi,can add manually |
if you using compile 'com.github.tcking:giraffeplayer2:0.1.25' or compile 'com.github.tcking:giraffeplayer2:0.1.25-full' and want to support more ABI:
…just call GiraffePlayer.play(getContext(), new VideoInfo("video url"));,all is done.
VideoView in your layout xml file
VideoView videoView = (VideoView) findViewById(R.id.video_view);
videoView.setVideoPath(videoUri).getPlayer().start();
in ListView or RecyclerView,you need do one more thing: call videoView.setFingerprint(),
the fingerprint is the key that player distinguish list items,you can using list position or list data's hashcode as fingerprint,eg:
public void onBindViewHolder(VideoItemHolder holder, int position) {
VideoItem videoItem = data.get(position);
holder.name.setText(videoItem.name);
holder.url.setText(videoItem.uri);
holder.videoView.setVideoPath(videoItem.uri).setFingerprint(position);// or using:setFingerprint(videoItem.hashCode())
}
all the configurations in VideoInfo,you can get VideoInfo and then set configurations,eg:
…-dontwarn tv.danmaku.ijk.media.player.**
-keep class tv.danmaku.ijk.media.player.** { *; }
-keep interface tv.danmaku.ijk.media.player.* { *; }lazy load
No open issues yet, or sync has not completed.