更新记录

1.2.0(2024-04-10)

新增支持base64格式返回图片,base64方法返回不会保存到相册

1.1.0(2022-11-15)

1、解决android高版本系统无法保存图片等问题。

1.0.0(2021-08-11)

初次发布插件

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 11.0 armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
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原生插件配置”->”云端插件“列表中删除该插件重新选择


Android获取本地、网络视频的封面图片、缩略图、第N帧图片、视频指定时间截图插件

请求参数说明

参数 说明 示例
videoPath 视频路径(本地、网络均可) file:///storage/emulated/0/Pictures/test.mp4
imagePath 图片保存文件夹名称 VideoCover
imageName 图片保存名称 test1628666711531.jpg
coverTime 时间(截取视频当前时间的画面为封面图片),单位:秒 1

回调参数说明

参数 说明 示例
code 结果码 200
coverPath 封面图片路径 file:///storage/emulated/0/VideoCover/test1628651342983.jpg
base64 图片base64 data:image/jpeg;base64,xxx
msg 错误信息 视频路径不能为空

结果码参数说明

Code 说明
200 获取成功(不是200均为获取失败)
401 视频路径不能为空
402 保存图片的地址不能为空
403 保存图片的名字不能为空
404 图片保存失败
405 其他错误

引用插件

const VideoCover = uni.requireNativePlugin('GT-VideoCover_Picture');

获取视频封面图片,base64格式返回

VideoCover.handleLocalVideoToBase64({
        videoPath: 'xxx', //视频路径
        coverTime: 1 //截取视频当前时间的图片作为封面,单位:秒
    },
    ret => {
        uni.hideLoading();
        if (ret && ret.code == 200) {
            console.log('=====成功result: ', ret);
        } else {
            console.log('=====失败result: ', ret);
        }
    }
);

获取本地视频封面图片

/**
 * 获取本地视频封面图片
 */
handleLocalVideo() {
    let that = this;
    uni.chooseVideo({
        count: 1,
        sourceType: ['album'],
        success: function(res) {
            // #ifndef APP-PLUS
            uni.showToast({
                title: '请在APP中测试',
                mask: true,
                duration: 1500,
                icon: 'none'
            });
            // #endif
            // #ifdef APP-PLUS
            uni.showLoading({
                title: 'loading...',
                mask: true
            });
            VideoCover.handleLocalVideo(
                {
                    videoPath: res.tempFilePath,  //视频路径
                    imagePath: 'VideoCover',  //图片保存文件夹名称
                    imageName: 'test'+(new Date()).getTime()+'.jpg', //图片保存名称
                    coverTime: 1  //截取视频当前时间的图片作为封面,单位:秒
                },
                ret => {
                    uni.hideLoading();
                    if (ret && ret.code == 200) {
                        console.log('===========================');
                        console.log('=====成功result: ', ret);
                        console.log('===========================');
                        that.videoCoverPath = ret.coverPath;
                        uni.showToast({
                            title: '成功: ' + ret.coverPath,
                            mask: true,
                            duration: 1500,
                            icon: 'none'
                        });
                    } else {
                        console.log('===========================');
                        console.log('=====失败result: ', ret);
                        console.log('===========================');
                        uni.showToast({
                            title: '失败: ' + ret.msg,
                            mask: true,
                            duration: 1500,
                            icon: 'none'
                        });
                    }
                }
            );
            // #endif
        }
    });
},

获取网络视频封面图片

/**
 * 获取网络视频封面图片
 */
handleNetworkVideo() {
    let that = this;
    // #ifndef APP-PLUS
    uni.showToast({
        title: '请在APP中测试',
        mask: true,
        duration: 1500,
        icon: 'none'
    });
    // #endif
    // #ifdef APP-PLUS
    uni.showLoading({
        title: 'loading...',
        mask: true
    });
    VideoCover.handleLocalVideo(
        {
            videoPath: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/a876efc0-4f35-11eb-97b7-0dc4655d6e68.mp4',  //视频路径
            imagePath: 'VideoCover',  //图片保存文件夹名称
            imageName: 'test'+(new Date()).getTime()+'.jpg', //图片保存名称
            coverTime: '80.5',//截取视频当前时间的图片作为封面,单位:秒
        },
        ret => {
            uni.hideLoading();
            if (ret && ret.code == 200) {
                console.log('===========================');
                console.log('=====成功result: ', ret);
                console.log('===========================');
                that.videoCoverPath = ret.coverPath;

                uni.showToast({
                    title: '成功: ' + ret.coverPath,
                    mask: true,
                    duration: 1500,
                    icon: 'none'
                });
            } else {
                console.log('===========================');
                console.log('=====失败result: ', ret);
                console.log('===========================');
                uni.showToast({
                    title: '失败: ' + ret.msg,
                    mask: true,
                    duration: 1500,
                    icon: 'none'
                });
            }
        }
    );
    // #endif
}

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问