项目开发中使用阿里云的点播功能,从中遇到了一堆坑,特写此笔记。希望对使用阿里云点播的伙伴们有所帮助。
一、讲解录制功能
首先赋上阿里云的官方录制文档 https://help.aliyun.com/document_detail/53421.html?spm=5176.doc53407.6.680.S2RrZX
在gradle文件中使用依赖的方式引用aar:
compile(name:'xxx',ext:'aar')
注意:目前闭源support版本的包必须跟以下版本一致.
```java
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'pub.devrel:easypermissions:0.2.1'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
compile 'com.squareup.okio:okio:1.12.0'
compile 'com.google.code.gson:gson:2.8.0'
录制基本上也就是这些,下面讲讲录制遇到的问题
1、加载不到.so文件。
肯定是.so文件加载姿势不对,我这边是因为项目中有百度的.so文件导致32位和64位不兼容,在build.gradle加入以下代码
defaultConfig{
ndk {
abiFilters"armeabi-v7a"//如果别的存放.so文件也冲突的话,把文件名继续追加存放就ok。
}
}
特别注意,在录制时候大多数人会遇到了这两个问题
uploader.addFile("" ,
"" );
uploadfilePath是上传视频的本地路径
2、播放:--阿里云提供的播放支持远程和本地播放(文档确实破,好多方法都是没有的,但文档上有。郁闷)
一:本地播放(文档是没有说明播放本地,所以记录一下)
private AliyunVodPlayer aliyunVodPlayer;
aliyunVodPlayer = new AliyunVodPlayer(this); //设置播放的surface aliyunVodPlayer.setDisplay(surfaceView.getHolder());
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) { aliyunVodPlayer.setDisplay(holder); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { aliyunVodPlayer.surfaceChanged(); } @Override public void surfaceDestroyed(SurfaceHolder holder) { } });
AliyunLocalSource.AliyunLocalSourceBuilder asb = new AliyunLocalSource.AliyunLocalSourceBuilder(); asb.setSource(path); AliyunLocalSource mLocalSource = asb.build(); aliyunVodPlayer.prepareAsync(mLocalSource);
我的项目中使用的是基础版的(只因公司穷),基础版改变不了ui界面,只能根据提供的style来替换图标。很low的!!
获取视频默认显示第一帧图片、视频大小、播放时长阿里云没有提供,需要自己通过java来获取。不会的可以问度娘耶。
就到这了,到饭点啦。希望对阿里云的伙伴有一点点帮助