更新记录

1.5(2021-06-01)

本次主要更新: 1.版本1.4的包 更新错了

1.4(2021-04-29)

本次主要更新: 1.适配andoird10+,修复targetSdkVersion>=29时,相册选择视频不能获取封面

1.3(2020-04-26)

本次主要更新: 1.修复卡顿现象

查看更多

平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 12.0 armeabi-v7a:支持,arm64-v8a:支持,x86:支持 适用版本区间:9 - 16

原生插件通用使用流程:

  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原生插件配置”->”云端插件“列表中删除该插件重新选择


KJ-VideoThumbnail

获取本地和网络视频缩略图、封面、第几帧图片(ios 、andorid)

使用

<template>
    <view class="content">
        <label>---本地视频获取的缩略图---</label>
        <image :src="localThumbnail">
        </image>

        <label>---网络视频获取的缩略图---</label>
        <image :src="networkThumbnail">
        </image>
        <input placeholder="请输入网络地址" v-model="url" />
        <button @click="network">获取网络地址</button>

        <label>---获取相册/录像视频缩略图---</label>
        <image :src="albumVideoThumbnail">
        </image>
        <button @click="albumVideo">相册/录像视频</button>

    </view>
</template>

<script>
    Date.prototype.Format = function(fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份 
            "d+": this.getDate(), //日 
            "h+": this.getHours(), //小时 
            "m+": this.getMinutes(), //分 
            "s+": this.getSeconds(), //秒 
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
            "S": this.getMilliseconds() //毫秒 
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k])
                    .length)));
            }
        }
        return fmt;
    }
    export default {
        data() {
            return {
                localThumbnail: '',
                networkThumbnail: '',
                url: "https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/a876efc0-4f35-11eb-97b7-0dc4655d6e68.mp4",
                albumVideoThumbnail: ''
            }
        },
        onLoad() {
            this.local();
            this.network();
        },
        methods: {
            getVideoThumbnailImage(videoPath, type) {
                /**
                 * videoPath - 必须传本地绝对路径,路径不要存在“file://”,有的话就去掉
                 * saveImagePath - 保存缩略图的路径,必须传_doc下的本地绝对路径
                 * */
                var dic = {
                    "videoPath": videoPath,
                    "saveImagePath": plus.io.convertLocalFileSystemURL(
                        "_doc/KJ-VideoThumbnail/"), //保存缩略图的路径,必须传_doc下的本地绝对路径
                    "saveImageName": new Date().Format("yyyyMMddhhmmss") + ".png",
                    "second": "0.0" //单位:秒,字符串类型
                };
                console.log(JSON.stringify(dic));
                const KJVideoThumbnail = uni.requireNativePlugin('KJ-VideoThumbnail');
                KJVideoThumbnail.getVideoThumbnailImage(dic, (result) => {
                    console.log(JSON.stringify(result));
                    //返回数据示例:{"error":"","code":1,"imagePath":"file:///storage/emulated/0/Android/data/uni.UNIBFB95EF/apps/__UNI__BFB95EF/doc/KJ-VideoThumbnail/localThumbnail.png"}
                    //返回的数据说明:code等于0为失败,code等于1为成功,imagePath为缩略图的路径
                    var imagePath = result["imagePath"]
                    if (type == "localThumbnail") {
                        this.localThumbnail = imagePath;
                    } else if (type == "networkThumbnail") {
                        this.networkThumbnail = imagePath;
                    } else if (type == "albumVideoThumbnail") {
                        this.albumVideoThumbnail = imagePath;
                    }
                });
            },
            local() {
                this.getVideoThumbnailImage(plus.io.convertLocalFileSystemURL("static/test.mp4"), "localThumbnail")
            },
            network() {
                this.getVideoThumbnailImage(this.url, "networkThumbnail")
            },
            albumVideo() {
                uni.chooseVideo({
                    sourceType: ['album', 'camera'],
                    success: (res) => {
                        var path = plus.io.convertLocalFileSystemURL(res.tempFilePath);
                        this.getVideoThumbnailImage(path, "albumVideoThumbnail")
                    }
                });
            }
        }
    }
</script>

<style>
    .content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    image {
        width: 100px;
        height: 100px;
    }

    label {
        padding: 10px;
    }
</style>

隐私、权限声明

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

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

插件不采集任何数据

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

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