内嵌播放器JCVideoPlayer

##主要特点

  1. 视频全屏播放和浮层小窗播放
  2. 可以完全自定义UI
  3. 能在ListViewViewPagerListViewViewPagerFragment等多重嵌套模式下全屏工作
  4. 手势修改进度和音量
  5. 视频大小的屏幕适配,宽或长至少有两个对边是充满屏幕的,另外两个方向居中
  6. 可以在加载、暂停、播放等各种状态中正常进入全屏和退出全屏
  7. 支持hls,rtsp
  8. 设置http头信息
  9. 重力感应自动全屏

##使用

1.添加类库

compile 'fm.jiecao:jiecaovideoplayer:4.6.3'

或直接下载

https://github.com/ashLikun/JCVideoPlayer/blob/master/README-ZH.md

2.添加布局

<JCVideoPlayerStandard
    android:id="@+id/custom_videoplayer_standard"
    android:layout_width="match_parent"
    android:layout_height="200dp"/>

3.设置视频地址、缩略图地址、标题

JCVideoPlayerStandard jcVideoPlayerStandard = (JCVideoPlayerStandard) findViewById(R.id.custom_videoplayer_standard);
jcVideoPlayerStandard.setUp("http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4"
                            , JCVideoPlayerStandard.SCREEN_LAYOUT_LIST, "嫂子闭眼睛");
下面注释掉的最新包改变了使用方法:viewHolder.jcv_videoplayer.thumbImageView.setImageURI(Uri.parse(mediaItem.getVideo().getThumbnail().get(0)));
//jcVideoPlayerStandard.thumbImageView.setThumbInCustomProject("http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640");

4.在Activity

@Override
public void onBackPressed() {
    if (JCVideoPlayer.backPress()) {
        return;
    }
    super.onBackPressed();
}
@Override
protected void onPause() {
    super.onPause();
    JCVideoPlayer.releaseAllVideos();
}

####其他接口

直接进入全屏

JCVideoPlayerStandard.startFullscreen(this, JCVideoPlayerStandard.class, "http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4", "嫂子辛苦了");

重力感应自动进入全屏

JCVideoPlayer.JCAutoFullscreenListener sensorEventListener;
SensorManager                          sensorManager;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    sensorEventListener = new JCVideoPlayer.JCAutoFullscreenListener();
}
@Override
protected void onResume() {
    super.onResume();
    Sensor accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    sensorManager.registerListener(sensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onPause() {
    super.onPause();
    sensorManager.unregisterListener(sensorEventListener);
}

####混淆

-keep class tv.danmaku.ijk.** { *; }
-dontwarn tv.danmaku.ijk.**

播放Assets文件夹下的视频,请先拷贝到本地路径再播放.亲测如果直接传参数IMediaDataSource,只停留在第一帧画面上并且后台会报错




你可能感兴趣的:(Android,android手机影音细节)