/**
options 中的参数,我在csdn中找过很多篇文章了,有的文章一个参数也没写,有的写的都是关于缓存的,还有的写了几个,也没说明是什么意思
然后只能跑到csdn下载文档查看,为了方便网友们的使用,这里就简单写一下我是怎么使用的,后面会附上options的参数意义
position就是当前播放第几条
media.setHWDecoderEnabled(true,true);//开启硬件加速 参考的网友的代码
surfaceView就是容器了,这个在布局中自己定义一下就行
*/
public void CreateVlcManager(int position){
releasePlayer();
if(mList!=null&&mList.size()>0&&position<mList.size()){
MediaDetailBean bean = mList.get(position);
String url = bean.getUrl();
toast("url:"+url);
ArrayList<String> options = new ArrayList<>();
options.add("--aout=opensles");//音频输出模块opensles模式
options.add("--audio-time-stretch");
options.add("-vvv");
options.add("--no-skip-frames");//关闭 跳过帧
options.add("--deinterlace=1");
options.add("--deinterlace-mode=blend");//解除交错模式
libVLC = new LibVLC(getApplicationContext(), options);
mediaPlayer = new MediaPlayer(libVLC);
media = new Media(libVLC, Uri.parse(url));
media.setHWDecoderEnabled(true,true);//开启硬件加速
mediaPlayer.setMedia(media);
ivlcVout = mediaPlayer.getVLCVout();
ivlcVout.setVideoView(surfaceView);
ivlcVout.addCallback(this);
ivlcVout.attachViews();
mediaPlayer.play();
mediaPlayer.setEventListener(this);
}
}
private void releasePlayer() {
if (libVLC == null) {
return;
}
try {
if (media.getDuration() > 0) {
mediaPlayer.stop();
} else {
mediaPlayer.stop();
}
ivlcVout.removeCallback(this);
ivlcVout.detachViews();
surfaceHolder = null;
libVLC.release();
libVLC = null;
mediaPlayer = null;
} catch (Exception e) {
e.printStackTrace();
}
}
关于options中参数的意义(仅供参考)
| 音频 |
| --audio, --no-audio |
打开音频 (默认打开) |
|
| --volume |
默认音量 |
<整型> |
| --volume-step |
输出音量步长 |
<整型> |
| --aout-rate |
音频输出频率(Hz) |
<整型> |
| --hq-resampling, --no-hq-resampling |
高质量音频采样 (默认打开) |
|
| --spdif, --no-spdif |
当可用时使用 S/PDIF音频输出 (默认关闭) |
|
| --force-dolby-surround |
强制检测杜比环绕 {0 (自动), 1 (开), 2 (关)} |
|
| --audio-desync |
音频异步校正 |
<整型> |
| --aout |
音频输出模块 |
<字符串型> |
| --audio-filter |
音频滤波器 |
<字符串型> |
| --audio-visual |
音频视觉效果 |
<字符串型> |
| |
|
|
| 视频 |
| --video, --no-video |
启动视频 (默认打开) |
|
| --grayscale, --no-grayscale |
灰度视频输出 (默认关闭) |
|
| --f, --fullscreen, --no-fullscreen |
全屏幕视频输出 (默认关闭) |
|
| --drop-late-frames, --no-drop-late-frames |
丢弃晚的帧 (默认打开) |
|
| --skip-frames, --no-skip-frames |
跳过帧 (默认打开) |
|
| --quiet-synchro, --no-quiet-synchro |
静音同步 (默认关闭) |
|
| --overlay, --no-overlay |
重叠视频输出 (默认打开) |
|
| --video-on-top, --no-video-on-top |
永远在最上层 (默认关闭) |
|
| --disable-screensaver, --no-disable-screensaver |
关闭屏幕保护程序 (默认打开) |
|
| --snapshot-path |
视频快照目录 (或文件名) |
<字符串型> |
| --snapshot-prefix |
视频快照文件前缀 |
<字符串型> |
| --snapshot-format |
视频快照格式 |
{png,jpg} |
| --snapshot-preview, --no-snapshot-preview |
显示视频快照预览 (默认打开) |
|
| --snapshot-sequential, --no-snapshot-sequential |
使用有序数字代替时间戳 (默认关闭) |
|
| --width |
视频宽度 |
<整型> |
| --height |
视频高度 |
<整型> |
| --video-x |
视频 X 坐标 |
<整型> |
| --video-y |
视频 Y 坐标 |
<整型> |
| --crop |
视频修整 |
<字符串型> |
| --custom-crop-ratios |
自定义修整比率列表 |
<字符串型> |
| --aspect-ratio |
源比率 |
<字符串型> |
| --monitor-par |
监视器像素纵横比 |
<字符串型> |
| --custom-aspect-ratios |
自定义纵横比列表 |
<字符串型> |
| --hdtv-fix, --no-hdtv-fix 固定 HDTV 高度 (默认打开) |
|
|
| --video-deco, --no-video-deco |
窗口装饰 (默认打开) |
|
| --video-title |
视频标题 |
<字符串型> |
| --align |
视频对齐 |
{0 (居中), 1 (左), 2 (右), 4 (顶部), 8 (底部), 5 (左上), 6 (右上), 9 (左下), 10 (右下)} |
| --zoom |
缩放视频 |
<浮点型> |
| --vout |
视频输出模块 |
<字符串型> |
| --vout-filter |
视频过滤器模块 |
<字符串型> |
| |
|
|
| 译码器 |
| --codec |
偏好的解码器清单 |
<字符串型> |
| --encoder |
偏好的编码器清单输入 |
<字符串型> |
| --access |