更新记录
0.0.10(2022-01-17)
- 优化播放按钮UI;
- 修复标签显示过长问题;
0.0.9(2022-01-01)
- 修复封面预加载闪退问题;
0.0.8(2021-12-29)
- 修复部分机型黑屏问题;
平台兼容性
Android | Android CPU类型 | iOS |
---|---|---|
适用版本区间:5.0 - 11.0 | armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 | × |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在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(Android)
1. 插件名称
Hs-VideoList
2. 使用方法
在要使用的页面添加组件
<hsVideoList ref="hsVideo" :style="boxStyle" style="background-color: #000000;" @sendEvent="sendEvent">
</hsVideoList>
初始化
hsVideo = this.$refs.hsVideo;
hsVideo.initData({
"baseUrl": "视频和封面图片的域名,如果视频对象的视频和封面路径是完整地址的,这个传空字符串就可以了",
"playPic": "播放图片名称(static目录下面)",
"likePic": "点赞图片名称(static目录下面)",
"unlikePic": "取消点赞图片名称(static目录下面)",
"commentPic": "评论图片名称(static目录下面)",
"morePic": "更多图片名称(static目录下面)",
"showLocation":"是否显示位置(ture or false)",
"showRing":"是否显示右下角的圆形(true or false)",
"loopPlay":"是否循环播放(true or false)",
"autoPlay":"是否自动播放",
"slideDirection": 1,//滑动方向 1.垂直 2.水平
"data": [{
"width": 1920,
"height": 1080,
"nickname": "nickname",
"avatar": "head/20210427/H_161949825895abe8ae239640e2.jpg",
"title": "title",
"shares": 0,
"uid": 1000045,
"cover": "",
"video": "/video/2887204/1000045-60891933b8ed2.mp4",
"username": "13631312058",
"video_id": 173,
"v_uid": 1000045,
"zans": 65667,
"talks": 0,
"muted": "false",
"playState": "pause",
"is_fans_it": false,
"operation": 1,
"topics": [
"name": "开心",
"topicsId": 5
]
}]
}
//全局播放状态监听
var globalEvent = uni.requireNativePlugin('globalEvent');
globalEvent.addEventListener('playStatusCallback', function(e) {
STATE_ERROR = -1;
STATE_IDLE = 0;
STATE_PREPARING = 1;
STATE_PREPARED = 2;
STATE_PLAYING = 3;
STATE_PAUSED = 4;
STATE_PLAYBACK_COMPLETED = 5;
STATE_BUFFERING = 6;
STATE_BUFFERED = 7;
STATE_START_ABORT = 8;//开始播放中止
});
3. data列表的数据对象说明
id | string | 用户ID |
---|---|---|
nickname | string | 用户昵称 |
video_id | int | 视频ID |
zans | int | 点赞量 |
talks | int | 评论量 |
shares | int | 分享量 |
is_fans_it | int | 是否关注TA,0:否,1:是 |
operation | int | 点赞动作,0:取消点赞,1:点赞 |
cover | string | 封面地址 |
video | string | 视频地址 |
avatar | string | 头像 |
title | string | 当时想法,纯文字 |
topics_name | string | 话题名字 |
topic_id | int | 话题ID |
4. 方法说明
添加数据
var param = {
"width": 1920,
"height": 1080,
"nickname": "nickname",
"avatar": "head/20210427/H_161949825895abe8ae239640e2.jpg",
"title": "title",
"shares": 0,
"uid": 1000045,
"cover": "",
"video": "/video/2887204/1000045-60891933b8ed2.mp4",
"username": "13631312058",
"video_id": 173,
"v_uid": 1000045,
"zans": 65667,
"talks": 0,
"muted": "false",
"playState": "pause",
"is_fans_it": false,
"operation": 1,
"topics": [
"name": "开心",
"topicsId": 5
]
};
hsVideo = this.$refs.hsVideo;
hsVideo.loadData(param);
更新数据(根据video_id匹配)
var param = {
"width": 1920,
"height": 1080,
"nickname": "nickname",
"avatar": "head/20210427/H_161949825895abe8ae239640e2.jpg",
"title": "title",
"shares": 0,
"uid": 1000045,
"cover": "",
"video": "/video/2887204/1000045-60891933b8ed2.mp4",
"username": "13631312058",
"video_id": 173,
"v_uid": 1000045,
"zans": 65667,
"talks": 0,
"muted": "false",
"playState": "pause",
"is_fans_it": false,
"operation": 1,
"topics": [
"name": "开心",
"topicsId": 5
]
};
hsVideo = this.$refs.hsVideo;
hsVideo.updateUserInfo(param);
设置域名(视频和封面的域名,如果视频对象里面的视频和封面路径已经是全路径,这个可以不传)
hsVideo = this.$refs.hsVideo;
hsVideo.setBaseUrl(域名);
设置点赞按钮图片(图片放static目录下)
hsVideo = this.$refs.hsVideo;
hsVideo.setLikePic(图片名称);
设置取消点赞按钮图片(图片放static目录下)
hsVideo = this.$refs.hsVideo;
hsVideo.setUnlikePic(图片名称);
设置评论按钮图片(图片放static目录下)
hsVideo = this.$refs.hsVideo;
hsVideo.setCommentPic(图片名称);
设置播放按钮图片(图片放static目录下)
hsVideo = this.$refs.hsVideo;
hsVideo.setPlayPic(图片名称);
设置更多按钮图片(图片放static目录下)
hsVideo = this.$refs.hsVideo;
hsVideo.setMorePic(图片名称);
根据视频id移除视频
hsVideo = this.$refs.hsVideo;
hsVideo.remove(video_id);
播放当前视频(重新播放)
hsVideo = this.$refs.hsVideo;
hsVideo.start();
播放当前视频(继续播放)
hsVideo = this.$refs.hsVideo;
hsVideo.play();
暂停播放当前视频
hsVideo = this.$refs.hsVideo;
hsVideo.pause();
停止播放当前视频
hsVideo = this.$refs.hsVideo;
hsVideo.stop();