🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

miniprogram-ar-push

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniprogram-ar-push - npm Package Compare versions

Comparing version
1.0.10
to
1.0.11
+1
-1
package.json
{
"name": "miniprogram-ar-push",
"version": "1.0.10",
"version": "1.0.11",
"description": "",

@@ -5,0 +5,0 @@ "main": "miniprogram_dist/index.js",

+51
-43

@@ -11,5 +11,5 @@ # ar-push 推流组件

1. 注册微信小程序,登录小程序后台获取微信小程序appid,appSecrert,修改类目审核(社交、教育、医疗、政务民生、金融,目前只有这些支持),配置socket合法域名wss://域名:9095
1. 注册微信小程序,登录小程序后台获取微信小程序appid,appSecrert,修改类目审核(社交、教育、医疗、政务民生、金融,目前只有这些支持,[具体查看](<https://developers.weixin.qq.com/miniprogram/dev/component/live-pusher.html>)),配置socket合法域名`wss://域名`具体根据SDK文档指定的域名
2. 获取开发者信息
3. 开发-配置中开启“使用npm模块”,基础库选择2.4.0及以上,打开“不校验合法域名”、真机调试打开“调试”。集成miniprogram-ar-meet、miniprogram-ar-push、miniprogram-ar-play
3. 开发-配置中开启“使用npm模块”,基础库选择2.4.0及以上,打开“不校验合法域名”、真机调试打开“调试”。集成[miniprogram-ar-meet](https://www.npmjs.com/package/miniprogram-ar-meet)、[miniprogram-ar-push](https://www.npmjs.com/package/miniprogram-ar-push)、[miniprogram-ar-play](https://www.npmjs.com/package/miniprogram-ar-play)

@@ -29,3 +29,4 @@ # 使用说明

2. 在需要使用 slide-view 的页面 page.json 中添加 ar-push 自定义组件配置
2. 构建npm, 打开微信开发者工具,点击工具-npm构建
3. 在需要使用 slide-view 的页面 page.json 中添加 ar-push 自定义组件配置

@@ -43,25 +44,25 @@ ```

```
<!-- ar推流组件 -->
<ar-push
id="arPush"
width="{{pushWidth}}"
height="200"
coverImg=""
enableAudio="{{enableAudio}}"
enableVideo="{{enableVideo}}"
pushID="{{pubID}}"
pushURL="{{pushURL}}"
bindPushStatus="handlePushStatus"
bindNetStateChange="handlePushNetChange"
bindRoomEvent="handleRoomEvent">
</ar-push>
<view style="width: 100%; height: 200px;">
<!-- ar推流组件宽高设置的为100%,所以父容器需要设定宽高 -->
<ar-push
id="arPush"
coverImg=""
enableAudio="{{enableAudio}}"
enableVideo="{{enableVideo}}"
pubID="{{pubID}}"
pushURL="{{pushURL}}"
bindPushStatus="handlePushStatus"
bindNetStateChange="handlePushNetChange"
bindRoomEvent="handleRoomEvent">
</ar-push>
</view>
```
### ar-push的属性介绍如下:
|属性名|类型|默认值|是否必须|说明|
|--|--|--|--|--|--|
|pushURL|String|-|是|ar-push组件推流URL|
|id|String|-|是|用户获取组件的```LivePusherContext```来切换摄像头等[操作](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.html)。|
|width|Number|显示屏幕的宽度|是|ar-push组件的宽度|
|height|Number|0|是|ar-push组件的高度|
|--|--|--|--|--|
|id|String|-|是|自定义组件标识ID,用户通过自定义组件标识ID获取组件的```LivePusherContext```来切换摄像头等操作,点击[查看详情](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePusherContext.html)。|
|pubID|String|-|是|ar-push组件推流标识ID,通过参数通过SDK回调返回|
|pushURL|String|-|是|ar-push组件推流URL,通过参数通过SDK回调返回|
|coverImg|String|-|否|ar-push组件进入后台时推流的等待画面|

@@ -84,15 +85,14 @@ |enableAudio|Boolean|true|否|ar-push组件是否静音|

```
//that为当前页面对象
that.selectComponent('#arPush').pause()
//this为当前页面对象
this.selectComponent('#arPush').pause()
```
2. 恢复推流
```
//that为当前页面对象
that.selectComponent('#arPush').resume()
//this为当前页面对象
this.selectComponent('#arPush').resume()
```
3. 切换前后置摄像头
```
//that为当前页面对象
that.selectComponent('#arPush').switchCamera()
//this为当前页面对象
this.selectComponent('#arPush').switchCamera()
```

@@ -102,4 +102,4 @@

```
//that为当前页面对象
that.setData({
//this为当前页面对象
this.setData({
enableAudio: !this.data.enableAudio

@@ -111,4 +111,4 @@ });

```
//that为当前页面对象
that.setData({
//this为当前页面对象
this.setData({
enableVideo: !this.data.enableVideo

@@ -125,12 +125,10 @@ });

<!-- 推流组件,view包裹可自定义样式 -->
<view>
<view style="width: 100%; height: 200px;">
<!-- ar推流组件宽高设置的为100%,所以父容器需要设定宽高 -->
<ar-push
id="arPush"
width="{{pushWidth}}"
height="200"
coverImg=""
enableAudio="{{enableAudio}}"
enableVideo="{{enableVideo}}"
pushID="{{pubID}}"
pubID="{{pubID}}"
pushURL="{{pushURL}}"

@@ -173,3 +171,2 @@ bindPushStatus="handlePushStatus"

```
const _windowWidth = wx.getSystemInfoSync().windowWidth
const config = require('../../config.js');

@@ -180,3 +177,2 @@ let wxRTMeet = require('miniprogram-ar-meet');

Page({
/**

@@ -189,3 +185,2 @@ * 页面的初始数据

pushURL: '',
pushWidth: _windowWidth,
enableVideo: true,

@@ -200,2 +195,3 @@ enableAudio: false,

},
//恢复推流

@@ -205,2 +201,10 @@ resumePush () {

},
//截图
takeSnapshot () {
this.data.arPusherComponent.snapshot(res => {
console.log("截图结果", res);
});
},
//切换摄像头

@@ -210,2 +214,3 @@ switchCamera () {

},
//打开/关闭摄像头

@@ -217,2 +222,3 @@ enableCamera () {

},
//打开/关闭麦克风

@@ -224,2 +230,3 @@ enableMicphone () {

},
//退出房间

@@ -238,7 +245,8 @@ leaveRoom() {

let roomId = '' + options.roomid;
//会议实例
let wxmeet = new wxRTMeet();
that.setData({
wxmeet: wxmeet,
//推流组件,可以切换前后摄像头,打开或关闭音视频
arPusherComponent: that.selectComponent('#arPush')

@@ -245,0 +253,0 @@ });

@@ -1,3 +0,2 @@

// components/pusher.js
const _windowWidth = wx.getSystemInfoSync().windowWidth;
// const _windowWidth = wx.getSystemInfoSync().windowWidth;

@@ -9,10 +8,2 @@ Component({

properties: {
width: {// 组件显示区域的宽度
type: Number,
value: _windowWidth
},
height: {// 组件显示区域的高度
type: Number,
value: 0,
},
pubID: {

@@ -57,3 +48,2 @@ type: String,

let that = this;
// console.log('onPush', e);
if (!that.data.pusherContext) {

@@ -86,4 +76,4 @@ that.data.pusherContext = wx.createLivePusherContext('rtcpusher');

this.triggerEvent('PushStatus', {
code: e.details.errCode,
msg: e.details.errMsg,
code: e.detail.errCode,
msg: e.detail.errMsg,
});

@@ -107,19 +97,14 @@ },

// console.log('================= onWebRTCUserListPush method', msg);
if (!msg) {
if (!msg)
return;
}
var jsonDic = JSON.parse(msg);
if (!jsonDic) {
if (!jsonDic)
return;
}
// console.log("onWebRTCUserListPush.jsonDict:", jsonDic);
var newUserList = jsonDic.userlist;
// console.log('=== newUserList: ', JSON.stringify(newUserList));
if (!newUserList) {
if (!newUserList)
return;
}

@@ -199,4 +184,14 @@ let userList = that.data.userList;

},
//截图
snapshot: function snapshot(cb) {
var that = this;
that.data.pusherContext || (that.data.pusherContext = wx.createLivePusherContext("rtcpusher")), that.data.pusherContext && that.data.pusherContext.snapshot({
complete: function(res) {
cb(res);
}
});
}
}
})