更新记录
1.8.3(2022-02-16)
更新Android视频横屏录制
1.8.2(2022-01-18)
增加android裁减控制是否保存相册字段配置
1.8.1(2022-01-05)
增加Android11存储权限检测
查看更多平台兼容性
Android | Android CPU类型 | iOS |
---|---|---|
适用版本区间:4.4 - 14.0 | armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 | 适用版本区间:9 - 17 |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包
付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios
注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择
阿里云短视频(基础班)SDK插件
一、初始化
1. 插件对象
//插件对象
var sdkwx = uni.requireNativePlugin('ASV-Snap');
2. 检查权限
sdkwx.checkPermissions(function(res){
console.log(res);
});
3. 视频裁剪
sdkwx.startCrop({
frameRate:30,//帧率,建议20-30
gop:250,//关键帧间隔,建议1-300
videoQuality:1,//视频质量,取值0-5,分别表示SSD, HD, SD, LD, PD, EPD
ratioMode:2,//视频比例,取值0-2,分别表示3:4,1:1,9:16
resolutionMode:2,//分辨率,取值0-3,分别表示360P,480P,540P,720P
scaleMode:1,//裁剪模式,取值0-1,分别表示画面裁剪,画面填充
videoCodecs:0//视频编码方式,取值0-2,分别表示H264_HARDWARE(硬编),H264_SOFT_OPENH264(软编),H264_SOFT_FFMPEG(软编)
}, function(res){
console.log(res);
});
二、录制控件
1. 录制控件标签
<asv_recorder_view ref="recorderView" style="width: 100%;height: 400px;"></asv_recorder_view>
2. 设置录制回调
var recorderView = this.$refs.recorderView;
recorderView.setMaxDuration(30000);//设置最大30s
recorderView.setRecordCallBack(function(res){
console.log(res);
if (res.type == "") {
var duration = res.data;//进度
} else if (res.type == "onFinish") {
var path = res.data;//录制完成的视频路径
}
});
3. 设置视频录制参数
var recorderView = this.$refs.recorderView;
recorderView. initRecordConfig({
maxDuration:30000,//视频最长时间
minDuration:2000,//视频最短时间
gop:250,//关键帧间隔 建议1-300
videoQuality:1,//视频质量 0-5分别表示超清、高清、标清、低、很低、差
resolutionMode:2,//分辨率 0-3分别表示360P、480P、540P、720P
ratioMode:2,//视频比例 0-2分别表示3:4、1:1、9:16
videoCodec:0//视频编码方式 0-2分别表示硬编码、OPENH264软编、FFMPEG软编
});
4. 设置媒体信息
var recorderView = this.$refs.recorderView;
recorderView.setMediaInfo(JSONObject params);
5. 设置输出路径
var recorderView = this.$refs.recorderView;
var path = "";
recorderView.setOutputPath(path);
6. 设置质量
var recorderView = this.$refs.recorderView;
var quality = 2;
recorderView.setVideoQuality(quality);
7. 设置Bitrate
var recorderView = this.$refs.recorderView;
var bitrate = 0;
recorderView.setVideoBitrate(bitrate);
8. 设置Bitrate
var recorderView = this.$refs.recorderView;
var gop = 0;
recorderView.setGop(gop);
9. 设置回调
var recorderView = this.$refs.recorderView;
recorderView.setRecordCallBack(function(res){
console.log(res);
});
10. 开启预览
var recorderView = this.$refs.recorderView;
recorderView.startPreview();
11. 停止预览
var recorderView = this.$refs.recorderView;
recorderView.stopPreview();
12. 摄像头前后置
var recorderView = this.$refs.recorderView;
recorderView.switchCamera();
13. 设置light
var recorderView = this.$refs.recorderView;
var flashType = “”;
recorderView.setLight(flashType);
14. 摄像缩放比例
var recorderView = this.$refs.recorderView;
var rate = 1.0;
recorderView.setZoom(rate);
15. 设置ExposureCompensationRatio
var recorderView = this.$refs.recorderView;
var value = 1.0;
recorderView.setExposureCompensationRatio(value);
16. 设置聚焦模式
var recorderView = this.$refs.recorderView;
var mode = 0;
recorderView.setFocusMode(mode);
17. 设置焦点
var recorderView = this.$refs.recorderView;
var xRatio = 1.0;
var yRatio = 1.0;
recorderView.setFocus(xRatio,yRatio);
18. 设置旋转
var recorderView = this.$refs.recorderView;
var rotation = 0;
recorderView.setRotation(rotation);
19. 设置FaceDetectRotation
var recorderView = this.$refs.recorderView;
var rotation = 0;
recorderView.setFaceDetectRotation(rotation);
20. 设置setRecordRotation
var recorderView = this.$refs.recorderView;
var rotation = 0;
recorderView.setRecordRotation(rotation);
21. 设置mute
var recorderView = this.$refs.recorderView;
var isMute = false;
recorderView.setMute(isMute);
22. 设置最大间隔时间
var recorderView = this.$refs.recorderView;
var maxDurationMs = 300;
recorderView.setMaxDuration(maxDurationMs);
23. 设置最大间隔时间
var recorderView = this.$refs.recorderView;
var minDurationMs = 100;
recorderView.setMinDuration(minDurationMs);
24. 获取时长
var recorderView = this.$refs.recorderView;
recorderView.getDuration();
25. 获取段数
var recorderView = this.$refs.recorderView;
recorderView.getPartCount();
26. 删除最后部分
var recorderView = this.$refs.recorderView;
recorderView.deleteLastPart();
27. 删除选中部分
var recorderView = this.$refs.recorderView;
var index = 0;
recorderView.deletePart(index);
``
#### 28. 删除所有部分
var recorderView = this.$refs.recorderView; recorderView.deleteAllPart(); ``
29. 获取视频路径列表
var recorderView = this.$refs.recorderView;
recorderView.getVideoPathList();
30. 设置美颜等级
var recorderView = this.$refs.recorderView;
var level = 1;
recorderView.setBeautyLevel(level);
31. 设置美颜开关状态
var recorderView = this.$refs.recorderView;
var on = true;
recorderView.setBeautyStatus(boolean on);
32. 使用滤镜
var recorderView = this.$refs.recorderView;
var index = 0;
recorderView.applyFilter(index);
33. 拍照
var recorderView = this.$refs.recorderView;
var needBitmap = false;
recorderView.takePhoto(needBitmap);
34. 拍照无滤镜
var recorderView = this.$refs.recorderView;
var needBitmap = false;
recorderView.takePicture(needBitmap);
35. 开始录制
var recorderView = this.$refs.recorderView;
recorderView.startRecording();
36. 取消录制
var recorderView = this.$refs.recorderView;
recorderView.cancelRecording();
37. 停止录制
var recorderView = this.$refs.recorderView;
recorderView.stopRecording();
38. 结束录制
var recorderView = this.$refs.recorderView;
recorderView.finishRecording();
39. 结束录制编辑
var recorderView = this.$refs.recorderView;
recorderView.finishRecordingForEdit();
40. 结束录制编辑
var recorderView = this.$refs.recorderView;
recorderView.finishRecordingForEdit();