Files
capture-cordova-plugin/README.md
T
2021-10-01 15:48:34 +08:00

57 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 短视频拍摄+压缩插件
## 来源
Android 代码根据 https://github.com/mabeijianxi/small-video-record 修改。
## 安装方法
`cordova plugin add git+http://m.shuto.cn:8680/center/capture-cordova-plugin.git`
## 调用方法
```javascript
/**
* 拍摄
* @Param options 拍摄参数
* @Param 成功callback
* @Param 失败callback
*
*/
capture.capture(options, success, error);
```
```javascript
/**
* 参数说明
*/
options = {
needFull: true, // 是否全屏预览,一般性能好些的机器都可开启
width: 640, // 视频宽度(相当于手机竖拍时的高度)
height: 480, // 视频高度
maxTime: 15000, // 可录制最大长度,单位:毫秒
minTime: 3000, // 录制最小长度,不到这个长度的会被忽略?,单位:毫秒
maxFramerate: 24, // 最大帧率,这个参数似乎影响不是很大
bitrate: 580000, // 比特率,值越大,文件越大,理论上越清晰
thumbnailsTime: 1 // 用作缩略图的图片的截取时间,默认第1帧
}
```
## 说明
1. Android 需要设置最低 sdk 版本为24
```xml
<preference name="android-minSdkVersion" value="24" />
```
2. Android 中因使用到了外部存储 DCMI,但在 Android10SdkVersion 29)中会出现 file.mkdir() 无法创建的问题,因此要么指定要么小于 29 的 sdk,要么添加过渡期解决方案。需要注意到 Android11SdkVersion 30)开始这个过滤方案将失效,需要按照 Scoped Storage 的规范使用外部存储。
- 2.1 指定 sdk 版本
```xml
<preference name="android-targetSdkVersion" value="25" />
```
- 2.2 使用过渡方案
```xml
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:requestLegacyExternalStorage="true" />
</edit-config>
```
[示例 app](http://m.shuto.cn:8680/center/captureDemo.git)