@tencentcloud/trtc-component-wx 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +11 -0
- package/.eslintrc.js +101 -0
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/gulpfile.js +26 -0
- package/miniprogram_dist/index.js +183 -0
- package/miniprogram_dist/index.js.map +1 -0
- package/miniprogram_dist/trtc-player.js +245 -0
- package/miniprogram_dist/trtc-player.js.map +1 -0
- package/miniprogram_dist/trtc-player.json +4 -0
- package/miniprogram_dist/trtc-player.wxml +12 -0
- package/miniprogram_dist/trtc-player.wxss +16 -0
- package/miniprogram_dist/trtc-pusher.js +232 -0
- package/miniprogram_dist/trtc-pusher.js.map +1 -0
- package/miniprogram_dist/trtc-pusher.json +4 -0
- package/miniprogram_dist/trtc-pusher.wxml +19 -0
- package/miniprogram_dist/trtc-pusher.wxss +15 -0
- package/package.json +73 -0
- package/src/index.js +4 -0
- package/src/package.json +14 -0
- package/src/trtc-cloud-wx.js +46 -0
- package/src/trtc-player.js +72 -0
- package/src/trtc-player.json +4 -0
- package/src/trtc-player.wxml +12 -0
- package/src/trtc-player.wxss +16 -0
- package/src/trtc-pusher.js +64 -0
- package/src/trtc-pusher.json +4 -0
- package/src/trtc-pusher.wxml +19 -0
- package/src/trtc-pusher.wxss +15 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
module.exports =
|
|
2
|
+
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
+
/******/ // The module cache
|
|
4
|
+
/******/ var installedModules = {};
|
|
5
|
+
/******/
|
|
6
|
+
/******/ // The require function
|
|
7
|
+
/******/ function __webpack_require__(moduleId) {
|
|
8
|
+
/******/
|
|
9
|
+
/******/ // Check if module is in cache
|
|
10
|
+
/******/ if(installedModules[moduleId]) {
|
|
11
|
+
/******/ return installedModules[moduleId].exports;
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14
|
+
/******/ var module = installedModules[moduleId] = {
|
|
15
|
+
/******/ i: moduleId,
|
|
16
|
+
/******/ l: false,
|
|
17
|
+
/******/ exports: {}
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/
|
|
20
|
+
/******/ // Execute the module function
|
|
21
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
+
/******/
|
|
23
|
+
/******/ // Flag the module as loaded
|
|
24
|
+
/******/ module.l = true;
|
|
25
|
+
/******/
|
|
26
|
+
/******/ // Return the exports of the module
|
|
27
|
+
/******/ return module.exports;
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
+
/******/ __webpack_require__.m = modules;
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // expose the module cache
|
|
35
|
+
/******/ __webpack_require__.c = installedModules;
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // define getter function for harmony exports
|
|
38
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // create a fake namespace object
|
|
53
|
+
/******/ // mode & 1: value is a module id, require it
|
|
54
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
+
/******/ // mode & 4: return value when already ns object
|
|
56
|
+
/******/ // mode & 8|1: behave like require
|
|
57
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
+
/******/ if(mode & 8) return value;
|
|
60
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
+
/******/ var ns = Object.create(null);
|
|
62
|
+
/******/ __webpack_require__.r(ns);
|
|
63
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
+
/******/ return ns;
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/
|
|
68
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
+
/******/ __webpack_require__.n = function(module) {
|
|
70
|
+
/******/ var getter = module && module.__esModule ?
|
|
71
|
+
/******/ function getDefault() { return module['default']; } :
|
|
72
|
+
/******/ function getModuleExports() { return module; };
|
|
73
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
+
/******/ return getter;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // __webpack_public_path__
|
|
81
|
+
/******/ __webpack_require__.p = "";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 4);
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ([
|
|
89
|
+
/* 0 */
|
|
90
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
91
|
+
|
|
92
|
+
"use strict";
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
var mitt = __webpack_require__(1);
|
|
96
|
+
var TRTC = __webpack_require__(2);
|
|
97
|
+
|
|
98
|
+
var TrtcCloud = /** @class */function () {
|
|
99
|
+
function TrtcCloud() {
|
|
100
|
+
this.emitter = mitt();
|
|
101
|
+
this.init();
|
|
102
|
+
}
|
|
103
|
+
TrtcCloud.getTRTCShareInstance = function () {
|
|
104
|
+
console.log('@@TrtcCloud.instance1', TrtcCloud.instance);
|
|
105
|
+
if (!TrtcCloud.instance) {
|
|
106
|
+
TrtcCloud.instance = new TrtcCloud();
|
|
107
|
+
console.log('@@TrtcCloud.instance2', TrtcCloud.instance);
|
|
108
|
+
}
|
|
109
|
+
return TrtcCloud.instance;
|
|
110
|
+
};
|
|
111
|
+
TrtcCloud.prototype.init = function () {
|
|
112
|
+
this.TRTC = new TRTC(this);
|
|
113
|
+
this.EVENT = this.TRTC.EVENT;
|
|
114
|
+
};
|
|
115
|
+
TrtcCloud.prototype.on = function (eventName, handler) {
|
|
116
|
+
this.emitter.on(eventName, handler);
|
|
117
|
+
};
|
|
118
|
+
TrtcCloud.prototype.enterRoom = function (params, scene) {
|
|
119
|
+
var sdkAppId = params.sdkAppId,
|
|
120
|
+
userId = params.userId,
|
|
121
|
+
userSig = params.userSig,
|
|
122
|
+
roomId = params.roomId;
|
|
123
|
+
this.TRTC.createPusher({});
|
|
124
|
+
var pusher = this.TRTC.enterRoom({
|
|
125
|
+
sdkAppID: sdkAppId,
|
|
126
|
+
userID: userId,
|
|
127
|
+
userSig: userSig,
|
|
128
|
+
roomID: roomId,
|
|
129
|
+
enableMic: true,
|
|
130
|
+
enableCamera: true // 进房默认开启视频上行
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
this.emitter.emit('enterRoom', pusher);
|
|
134
|
+
};
|
|
135
|
+
return TrtcCloud;
|
|
136
|
+
}();
|
|
137
|
+
|
|
138
|
+
module.exports = TrtcCloud;
|
|
139
|
+
|
|
140
|
+
/***/ }),
|
|
141
|
+
/* 1 */
|
|
142
|
+
/***/ (function(module, exports) {
|
|
143
|
+
|
|
144
|
+
module.exports = require("mitt");
|
|
145
|
+
|
|
146
|
+
/***/ }),
|
|
147
|
+
/* 2 */
|
|
148
|
+
/***/ (function(module, exports) {
|
|
149
|
+
|
|
150
|
+
module.exports = require("trtc-wx-sdk");
|
|
151
|
+
|
|
152
|
+
/***/ }),
|
|
153
|
+
/* 3 */,
|
|
154
|
+
/* 4 */
|
|
155
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
156
|
+
|
|
157
|
+
"use strict";
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
var _trtcCloudWx = __webpack_require__(0);
|
|
161
|
+
|
|
162
|
+
var _trtcCloudWx2 = _interopRequireDefault(_trtcCloudWx);
|
|
163
|
+
|
|
164
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
165
|
+
|
|
166
|
+
var trtcCloud = _trtcCloudWx2.default.getTRTCShareInstance();
|
|
167
|
+
var trtc = trtcCloud.trtc;
|
|
168
|
+
var InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter;
|
|
169
|
+
|
|
170
|
+
Component({
|
|
171
|
+
properties: {
|
|
172
|
+
streamId: String
|
|
173
|
+
},
|
|
174
|
+
data: {
|
|
175
|
+
player: {},
|
|
176
|
+
TRTCStreamId: ''
|
|
177
|
+
},
|
|
178
|
+
lifetimes: {
|
|
179
|
+
attached: function attached() {
|
|
180
|
+
this.data.TRTCStreamId = this.getTRTCStreamId(this.data.streamId);
|
|
181
|
+
this.bindTRTCCloudEvent();
|
|
182
|
+
},
|
|
183
|
+
detached: function detached() {
|
|
184
|
+
this.unbindTRTCCloudEvent();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
methods: {
|
|
189
|
+
// todo room uniapp 特供,因为 uniapp 打包导致组件传惨变量名更替 trtc-player 组建内部无法识别
|
|
190
|
+
setTRTCStreamId: function setTRTCStreamId(id) {
|
|
191
|
+
var _this = this;
|
|
192
|
+
|
|
193
|
+
return new Promise(function (resolve, reject) {
|
|
194
|
+
try {
|
|
195
|
+
_this.data.streamId = id;
|
|
196
|
+
_this.data.TRTCStreamId = _this.getTRTCStreamId(id);
|
|
197
|
+
_this.setData({ streamId: _this.data.streamId }, function () {
|
|
198
|
+
resolve();
|
|
199
|
+
});
|
|
200
|
+
} catch (err) {
|
|
201
|
+
reject(err);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
playerAttributesChange: function playerAttributesChange(event) {
|
|
206
|
+
var view = event.view,
|
|
207
|
+
playerAttributes = event.playerAttributes,
|
|
208
|
+
callback = event.callback;
|
|
209
|
+
|
|
210
|
+
if (view === this.data.streamId) {
|
|
211
|
+
this.setData({ player: playerAttributes }, callback);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
getTRTCStreamId: function getTRTCStreamId(streamId) {
|
|
215
|
+
var tempArray = streamId.split('_');
|
|
216
|
+
var userId = tempArray.slice(0, -1).join('_');
|
|
217
|
+
var streamType = Number(tempArray[tempArray.length - 1]);
|
|
218
|
+
return (0, _trtcCloudWx.translateTRTCStreamId)(userId, streamType);
|
|
219
|
+
},
|
|
220
|
+
bindTRTCCloudEvent: function bindTRTCCloudEvent() {
|
|
221
|
+
InterfaceEventEmitter.on('playerAttributesChange', this.playerAttributesChange, this);
|
|
222
|
+
},
|
|
223
|
+
unbindTRTCCloudEvent: function unbindTRTCCloudEvent() {
|
|
224
|
+
InterfaceEventEmitter.off('playerAttributesChange', this.playerAttributesChange);
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
// 请保持跟 wxml 中绑定的事件名称一致
|
|
228
|
+
_playerStateChange: function _playerStateChange(event) {
|
|
229
|
+
trtc.playerEventHandler(event);
|
|
230
|
+
},
|
|
231
|
+
_playerFullscreenChange: function _playerFullscreenChange(event) {
|
|
232
|
+
trtc.playerFullscreenChange(event);
|
|
233
|
+
},
|
|
234
|
+
_playerNetStatus: function _playerNetStatus(event) {
|
|
235
|
+
trtc.playerNetStatus(event);
|
|
236
|
+
},
|
|
237
|
+
_playerAudioVolumeNotify: function _playerAudioVolumeNotify(event) {
|
|
238
|
+
trtc.playerAudioVolumeNotify(event);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
/***/ })
|
|
244
|
+
/******/ ]);
|
|
245
|
+
//# sourceMappingURL=trtc-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/trtc-cloud-wx.js","webpack:///external \"mitt\"","webpack:///external \"trtc-wx-sdk\"","webpack:///./src/trtc-player.js"],"names":["mitt","require","TRTC","TrtcCloud","emitter","init","getTRTCShareInstance","console","log","instance","prototype","EVENT","on","eventName","handler","enterRoom","params","scene","sdkAppId","userId","userSig","roomId","createPusher","pusher","sdkAppID","userID","roomID","enableMic","enableCamera","emit","module","exports","trtcCloud","TRTCCloud","trtc","InterfaceEventEmitter","Component","properties","streamId","String","data","player","TRTCStreamId","lifetimes","attached","getTRTCStreamId","bindTRTCCloudEvent","detached","unbindTRTCCloudEvent","methods","setTRTCStreamId","id","Promise","resolve","reject","setData","err","playerAttributesChange","event","view","playerAttributes","callback","tempArray","split","slice","join","streamType","Number","length","off","_playerStateChange","playerEventHandler","_playerFullscreenChange","playerFullscreenChange","_playerNetStatus","playerNetStatus","_playerAudioVolumeNotify","playerAudioVolumeNotify"],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA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xCO,4BAwCUhB,KAxCV,EAwCiB;AACtBxB,WAAKyC,eAAL,CAAqBjB,KAArB;AACD,KA1CM;AA2CPkB,4BA3CO,oCA2CkBlB,KA3ClB,EA2CyB;AAC9BxB,WAAK2C,uBAAL,CAA6BnB,KAA7B;AACD;AA7CM;AAlBD,CAAV,E","file":"trtc-player.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","'use strict';\n\nvar mitt = require('mitt');\nvar TRTC = require('trtc-wx-sdk');\n\nvar TrtcCloud = /** @class */function () {\n function TrtcCloud() {\n this.emitter = mitt();\n this.init();\n }\n TrtcCloud.getTRTCShareInstance = function () {\n console.log('@@TrtcCloud.instance1', TrtcCloud.instance);\n if (!TrtcCloud.instance) {\n TrtcCloud.instance = new TrtcCloud();\n console.log('@@TrtcCloud.instance2', TrtcCloud.instance);\n }\n return TrtcCloud.instance;\n };\n TrtcCloud.prototype.init = function () {\n this.TRTC = new TRTC(this);\n this.EVENT = this.TRTC.EVENT;\n };\n TrtcCloud.prototype.on = function (eventName, handler) {\n this.emitter.on(eventName, handler);\n };\n TrtcCloud.prototype.enterRoom = function (params, scene) {\n var sdkAppId = params.sdkAppId,\n userId = params.userId,\n userSig = params.userSig,\n roomId = params.roomId;\n this.TRTC.createPusher({});\n var pusher = this.TRTC.enterRoom({\n sdkAppID: sdkAppId,\n userID: userId,\n userSig: userSig,\n roomID: roomId,\n enableMic: true,\n enableCamera: true // 进房默认开启视频上行\n });\n\n this.emitter.emit('enterRoom', pusher);\n };\n return TrtcCloud;\n}();\n\nmodule.exports = TrtcCloud;\n","module.exports = require(\"mitt\");","module.exports = require(\"trtc-wx-sdk\");","import TRTCCloud, {translateTRTCStreamId} from 'trtc-cloud-wx'\n\nconst trtcCloud = TRTCCloud.getTRTCShareInstance()\nconst trtc = trtcCloud.trtc\nconst InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter\n\nComponent({\n properties: {\n streamId: String\n },\n data: {\n player: {},\n TRTCStreamId: ''\n },\n lifetimes: {\n attached() {\n this.data.TRTCStreamId = this.getTRTCStreamId(this.data.streamId)\n this.bindTRTCCloudEvent()\n },\n detached() {\n this.unbindTRTCCloudEvent()\n }\n },\n\n methods: {\n // todo room uniapp 特供,因为 uniapp 打包导致组件传惨变量名更替 trtc-player 组建内部无法识别\n setTRTCStreamId(id) {\n return new Promise((resolve, reject) => {\n try {\n this.data.streamId = id\n this.data.TRTCStreamId = this.getTRTCStreamId(id)\n this.setData({streamId: this.data.streamId}, () => {\n resolve()\n })\n } catch (err) {\n reject(err)\n }\n })\n },\n playerAttributesChange(event) {\n const {view, playerAttributes, callback} = event\n if (view === this.data.streamId) {\n this.setData({player: playerAttributes}, callback)\n }\n },\n getTRTCStreamId(streamId) {\n const tempArray = streamId.split('_')\n const userId = tempArray.slice(0, -1).join('_')\n const streamType = Number(tempArray[tempArray.length - 1])\n return translateTRTCStreamId(userId, streamType)\n },\n bindTRTCCloudEvent() {\n InterfaceEventEmitter.on('playerAttributesChange', this.playerAttributesChange, this)\n },\n unbindTRTCCloudEvent() {\n InterfaceEventEmitter.off('playerAttributesChange', this.playerAttributesChange)\n },\n // 请保持跟 wxml 中绑定的事件名称一致\n _playerStateChange(event) {\n trtc.playerEventHandler(event)\n },\n _playerFullscreenChange(event) {\n trtc.playerFullscreenChange(event)\n },\n _playerNetStatus(event) {\n trtc.playerNetStatus(event)\n },\n _playerAudioVolumeNotify(event) {\n trtc.playerAudioVolumeNotify(event)\n },\n }\n})\n"],"sourceRoot":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<view class="trtc-player-container">
|
|
2
|
+
<live-player wx:if="{{player.streamID}}" class="trtc-player" id="{{player.streamID}}" data-userid="{{player.userID}}"
|
|
3
|
+
data-streamid="{{player.streamID}}" data-streamtype="{{player.streamType}}" src="{{player.src}}" mode="RTC"
|
|
4
|
+
autoplay="{{player.autoplay}}" mute-audio="{{player.muteAudio}}" mute-video="{{player.muteVideo}}"
|
|
5
|
+
orientation="{{player.orientation}}" object-fit="{{player.objectFit}}"
|
|
6
|
+
background-mute="{{player.enableBackgroundMute}}" min-cache="{{player.minCache}}" max-cache="{{player.maxCache}}"
|
|
7
|
+
sound-mode="{{player.soundMode}}" enable-recv-message="{{player.enableRecvMessage}}"
|
|
8
|
+
auto-pause-if-navigate="{{player.autoPauseIfNavigate}}" auto-pause-if-open-native="{{player.autoPauseIfOpenNative}}"
|
|
9
|
+
debug="{{player.debug}}" bindstatechange="_playerStateChange" bindfullscreenchange="_playerFullscreenChange"
|
|
10
|
+
bindnetstatus="_playerNetStatus" bindaudiovolumenotify="_playerAudioVolumeNotify" />
|
|
11
|
+
<view wx:if="{{player.stopVideo}}" class="trtc-dark-mask"></view>
|
|
12
|
+
</view>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.trtc-player-container {
|
|
2
|
+
height: 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
position: relative;
|
|
5
|
+
}
|
|
6
|
+
.trtc-player {
|
|
7
|
+
height: 100%;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
.trtc-dark-mask {
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background-color: black;
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 0;
|
|
16
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
module.exports =
|
|
2
|
+
/******/ (function(modules) { // webpackBootstrap
|
|
3
|
+
/******/ // The module cache
|
|
4
|
+
/******/ var installedModules = {};
|
|
5
|
+
/******/
|
|
6
|
+
/******/ // The require function
|
|
7
|
+
/******/ function __webpack_require__(moduleId) {
|
|
8
|
+
/******/
|
|
9
|
+
/******/ // Check if module is in cache
|
|
10
|
+
/******/ if(installedModules[moduleId]) {
|
|
11
|
+
/******/ return installedModules[moduleId].exports;
|
|
12
|
+
/******/ }
|
|
13
|
+
/******/ // Create a new module (and put it into the cache)
|
|
14
|
+
/******/ var module = installedModules[moduleId] = {
|
|
15
|
+
/******/ i: moduleId,
|
|
16
|
+
/******/ l: false,
|
|
17
|
+
/******/ exports: {}
|
|
18
|
+
/******/ };
|
|
19
|
+
/******/
|
|
20
|
+
/******/ // Execute the module function
|
|
21
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
+
/******/
|
|
23
|
+
/******/ // Flag the module as loaded
|
|
24
|
+
/******/ module.l = true;
|
|
25
|
+
/******/
|
|
26
|
+
/******/ // Return the exports of the module
|
|
27
|
+
/******/ return module.exports;
|
|
28
|
+
/******/ }
|
|
29
|
+
/******/
|
|
30
|
+
/******/
|
|
31
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
+
/******/ __webpack_require__.m = modules;
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // expose the module cache
|
|
35
|
+
/******/ __webpack_require__.c = installedModules;
|
|
36
|
+
/******/
|
|
37
|
+
/******/ // define getter function for harmony exports
|
|
38
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ };
|
|
43
|
+
/******/
|
|
44
|
+
/******/ // define __esModule on exports
|
|
45
|
+
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
+
/******/ }
|
|
49
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
+
/******/ };
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // create a fake namespace object
|
|
53
|
+
/******/ // mode & 1: value is a module id, require it
|
|
54
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
+
/******/ // mode & 4: return value when already ns object
|
|
56
|
+
/******/ // mode & 8|1: behave like require
|
|
57
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
+
/******/ if(mode & 8) return value;
|
|
60
|
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
+
/******/ var ns = Object.create(null);
|
|
62
|
+
/******/ __webpack_require__.r(ns);
|
|
63
|
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
+
/******/ return ns;
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/
|
|
68
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
+
/******/ __webpack_require__.n = function(module) {
|
|
70
|
+
/******/ var getter = module && module.__esModule ?
|
|
71
|
+
/******/ function getDefault() { return module['default']; } :
|
|
72
|
+
/******/ function getModuleExports() { return module; };
|
|
73
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
+
/******/ return getter;
|
|
75
|
+
/******/ };
|
|
76
|
+
/******/
|
|
77
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // __webpack_public_path__
|
|
81
|
+
/******/ __webpack_require__.p = "";
|
|
82
|
+
/******/
|
|
83
|
+
/******/
|
|
84
|
+
/******/ // Load entry module and return exports
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
|
86
|
+
/******/ })
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ ([
|
|
89
|
+
/* 0 */
|
|
90
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
91
|
+
|
|
92
|
+
"use strict";
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
var mitt = __webpack_require__(1);
|
|
96
|
+
var TRTC = __webpack_require__(2);
|
|
97
|
+
|
|
98
|
+
var TrtcCloud = /** @class */function () {
|
|
99
|
+
function TrtcCloud() {
|
|
100
|
+
this.emitter = mitt();
|
|
101
|
+
this.init();
|
|
102
|
+
}
|
|
103
|
+
TrtcCloud.getTRTCShareInstance = function () {
|
|
104
|
+
console.log('@@TrtcCloud.instance1', TrtcCloud.instance);
|
|
105
|
+
if (!TrtcCloud.instance) {
|
|
106
|
+
TrtcCloud.instance = new TrtcCloud();
|
|
107
|
+
console.log('@@TrtcCloud.instance2', TrtcCloud.instance);
|
|
108
|
+
}
|
|
109
|
+
return TrtcCloud.instance;
|
|
110
|
+
};
|
|
111
|
+
TrtcCloud.prototype.init = function () {
|
|
112
|
+
this.TRTC = new TRTC(this);
|
|
113
|
+
this.EVENT = this.TRTC.EVENT;
|
|
114
|
+
};
|
|
115
|
+
TrtcCloud.prototype.on = function (eventName, handler) {
|
|
116
|
+
this.emitter.on(eventName, handler);
|
|
117
|
+
};
|
|
118
|
+
TrtcCloud.prototype.enterRoom = function (params, scene) {
|
|
119
|
+
var sdkAppId = params.sdkAppId,
|
|
120
|
+
userId = params.userId,
|
|
121
|
+
userSig = params.userSig,
|
|
122
|
+
roomId = params.roomId;
|
|
123
|
+
this.TRTC.createPusher({});
|
|
124
|
+
var pusher = this.TRTC.enterRoom({
|
|
125
|
+
sdkAppID: sdkAppId,
|
|
126
|
+
userID: userId,
|
|
127
|
+
userSig: userSig,
|
|
128
|
+
roomID: roomId,
|
|
129
|
+
enableMic: true,
|
|
130
|
+
enableCamera: true // 进房默认开启视频上行
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
this.emitter.emit('enterRoom', pusher);
|
|
134
|
+
};
|
|
135
|
+
return TrtcCloud;
|
|
136
|
+
}();
|
|
137
|
+
|
|
138
|
+
module.exports = TrtcCloud;
|
|
139
|
+
|
|
140
|
+
/***/ }),
|
|
141
|
+
/* 1 */
|
|
142
|
+
/***/ (function(module, exports) {
|
|
143
|
+
|
|
144
|
+
module.exports = require("mitt");
|
|
145
|
+
|
|
146
|
+
/***/ }),
|
|
147
|
+
/* 2 */
|
|
148
|
+
/***/ (function(module, exports) {
|
|
149
|
+
|
|
150
|
+
module.exports = require("trtc-wx-sdk");
|
|
151
|
+
|
|
152
|
+
/***/ }),
|
|
153
|
+
/* 3 */
|
|
154
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
155
|
+
|
|
156
|
+
"use strict";
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
var _trtcCloudWx = __webpack_require__(0);
|
|
160
|
+
|
|
161
|
+
var _trtcCloudWx2 = _interopRequireDefault(_trtcCloudWx);
|
|
162
|
+
|
|
163
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
164
|
+
|
|
165
|
+
var trtcCloud = _trtcCloudWx2.default.getTRTCShareInstance();
|
|
166
|
+
var trtc = trtcCloud.trtc;
|
|
167
|
+
var InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter;
|
|
168
|
+
|
|
169
|
+
Component({
|
|
170
|
+
properties: {
|
|
171
|
+
// trtcCloud: {
|
|
172
|
+
// type: Object,
|
|
173
|
+
// }
|
|
174
|
+
},
|
|
175
|
+
data: {
|
|
176
|
+
pusher: {}
|
|
177
|
+
},
|
|
178
|
+
lifetimes: {
|
|
179
|
+
attached: function attached() {
|
|
180
|
+
this.bindTRTCCloudEvent();
|
|
181
|
+
},
|
|
182
|
+
detached: function detached() {
|
|
183
|
+
this.unbindTRTCCloudEvent();
|
|
184
|
+
trtcCloud.exitRoom();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
methods: {
|
|
189
|
+
pusherAttributesChange: function pusherAttributesChange(event) {
|
|
190
|
+
var pusher = event.pusher,
|
|
191
|
+
callback = event.callback;
|
|
192
|
+
|
|
193
|
+
this.setData({ pusher: pusher }, callback);
|
|
194
|
+
},
|
|
195
|
+
bindTRTCCloudEvent: function bindTRTCCloudEvent() {
|
|
196
|
+
InterfaceEventEmitter.on('pusherAttributesChange', this.pusherAttributesChange, this);
|
|
197
|
+
},
|
|
198
|
+
unbindTRTCCloudEvent: function unbindTRTCCloudEvent() {
|
|
199
|
+
InterfaceEventEmitter.off('playerAttributesChange', this.pusherAttributesChange);
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// 请保持跟 wxml 中绑定的事件名称一致
|
|
203
|
+
_pusherStateChangeHandler: function _pusherStateChangeHandler(event) {
|
|
204
|
+
trtc.pusherEventHandler(event);
|
|
205
|
+
},
|
|
206
|
+
_pusherNetStatusHandler: function _pusherNetStatusHandler(event) {
|
|
207
|
+
trtc.pusherNetStatusHandler(event);
|
|
208
|
+
},
|
|
209
|
+
_pusherErrorHandler: function _pusherErrorHandler(event) {
|
|
210
|
+
trtc.pusherErrorHandler(event);
|
|
211
|
+
},
|
|
212
|
+
_pusherBGMStartHandler: function _pusherBGMStartHandler(event) {
|
|
213
|
+
trtc.pusherBGMStartHandler(event);
|
|
214
|
+
},
|
|
215
|
+
_pusherBGMProgressHandler: function _pusherBGMProgressHandler(event) {
|
|
216
|
+
trtc.pusherBGMProgressHandler(event);
|
|
217
|
+
},
|
|
218
|
+
_pusherBGMCompleteHandler: function _pusherBGMCompleteHandler(event) {
|
|
219
|
+
trtc.pusherBGMCompleteHandler(event);
|
|
220
|
+
},
|
|
221
|
+
_pusherAudioVolumeNotify: function _pusherAudioVolumeNotify(event) {
|
|
222
|
+
if (!trtcCloud.isEnterRoom) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
trtc.pusherAudioVolumeNotify(event);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
/***/ })
|
|
231
|
+
/******/ ]);
|
|
232
|
+
//# sourceMappingURL=trtc-pusher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/trtc-cloud-wx.js","webpack:///external \"mitt\"","webpack:///external \"trtc-wx-sdk\"","webpack:///./src/trtc-pusher.js"],"names":["mitt","require","TRTC","TrtcCloud","emitter","init","getTRTCShareInstance","console","log","instance","prototype","EVENT","on","eventName","handler","enterRoom","params","scene","sdkAppId","userId","userSig","roomId","createPusher","pusher","sdkAppID","userID","roomID","enableMic","enableCamera","emit","module","exports","trtcCloud","TRTCCloud","trtc","InterfaceEventEmitter","Component","properties","data","lifetimes","attached","bindTRTCCloudEvent","detached","unbindTRTCCloudEvent","exitRoom","methods","pusherAttributesChange","event","callback","setData","off","_pusherStateChangeHandler","pusherEventHandler","_pusherNetStatusHandler","pusherNetStatusHandler","_pusherErrorHandler","pusherErrorHandler","_pusherBGMStartHandler","pusherBGMStartHandler","_pusherBGMProgressHandler","pusherBGMProgressHandler","_pusherBGMCompleteHandler","pusherBGMCompleteHandler","_pusherAudioVolumeNotify","isEnterRoom","pusherAudioVolumeNotify"],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,i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ACAK,6BAZO,qCAYmBJ,KAZnB,EAY0B;AAC/Bb,WAAKkB,kBAAL,CAAwBL,KAAxB;AACD,KAdM;AAePM,2BAfO,mCAeiBN,KAfjB,EAewB;AAC7Bb,WAAKoB,sBAAL,CAA4BP,KAA5B;AACD,KAjBM;AAkBPQ,uBAlBO,+BAkBaR,KAlBb,EAkBoB;AACzBb,WAAKsB,kBAAL,CAAwBT,KAAxB;AACD,KApBM;AAqBPU,0BArBO,kCAqBgBV,KArBhB,EAqBuB;AAC5Bb,WAAKwB,qBAAL,CAA2BX,KAA3B;AACD,KAvBM;AAwBPY,6BAxBO,qCAwBmBZ,KAxBnB,EAwB0B;AAC/Bb,WAAK0B,wBAAL,CAA8Bb,KAA9B;AACD,KA1BM;AA2BPc,6BA3BO,qCA2BmBd,KA3BnB,EA2B0B;AAC/Bb,WAAK4B,wBAAL,CAA8Bf,KAA9B;AACD,KA7BM;AA8BPgB,4BA9BO,oCA8BkBhB,KA9BlB,EA8ByB;AAC9B,UAAI,CAACf,UAAUgC,WAAf,EAA4B;AAC1B;AACD;AACD9B,WAAK+B,uBAAL,CAA6BlB,KAA7B;AACD;AAnCM;AApBD,CAAV,E","file":"trtc-pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","'use strict';\n\nvar mitt = require('mitt');\nvar TRTC = require('trtc-wx-sdk');\n\nvar TrtcCloud = /** @class */function () {\n function TrtcCloud() {\n this.emitter = mitt();\n this.init();\n }\n TrtcCloud.getTRTCShareInstance = function () {\n console.log('@@TrtcCloud.instance1', TrtcCloud.instance);\n if (!TrtcCloud.instance) {\n TrtcCloud.instance = new TrtcCloud();\n console.log('@@TrtcCloud.instance2', TrtcCloud.instance);\n }\n return TrtcCloud.instance;\n };\n TrtcCloud.prototype.init = function () {\n this.TRTC = new TRTC(this);\n this.EVENT = this.TRTC.EVENT;\n };\n TrtcCloud.prototype.on = function (eventName, handler) {\n this.emitter.on(eventName, handler);\n };\n TrtcCloud.prototype.enterRoom = function (params, scene) {\n var sdkAppId = params.sdkAppId,\n userId = params.userId,\n userSig = params.userSig,\n roomId = params.roomId;\n this.TRTC.createPusher({});\n var pusher = this.TRTC.enterRoom({\n sdkAppID: sdkAppId,\n userID: userId,\n userSig: userSig,\n roomID: roomId,\n enableMic: true,\n enableCamera: true // 进房默认开启视频上行\n });\n\n this.emitter.emit('enterRoom', pusher);\n };\n return TrtcCloud;\n}();\n\nmodule.exports = TrtcCloud;\n","module.exports = require(\"mitt\");","module.exports = require(\"trtc-wx-sdk\");","import TRTCCloud from 'trtc-cloud-wx'\n\nconst trtcCloud = TRTCCloud.getTRTCShareInstance()\nconst trtc = trtcCloud.trtc\nconst InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter\n\nComponent({\n properties: {\n // trtcCloud: {\n // type: Object,\n // }\n },\n data: {\n pusher: {},\n },\n lifetimes: {\n attached() {\n this.bindTRTCCloudEvent()\n },\n detached() {\n this.unbindTRTCCloudEvent()\n trtcCloud.exitRoom()\n },\n },\n\n\n methods: {\n pusherAttributesChange(event) {\n const {pusher, callback} = event\n this.setData({pusher}, callback)\n },\n bindTRTCCloudEvent() {\n InterfaceEventEmitter.on('pusherAttributesChange', this.pusherAttributesChange, this)\n },\n unbindTRTCCloudEvent() {\n InterfaceEventEmitter.off('playerAttributesChange', this.pusherAttributesChange)\n },\n // 请保持跟 wxml 中绑定的事件名称一致\n _pusherStateChangeHandler(event) {\n trtc.pusherEventHandler(event)\n },\n _pusherNetStatusHandler(event) {\n trtc.pusherNetStatusHandler(event)\n },\n _pusherErrorHandler(event) {\n trtc.pusherErrorHandler(event)\n },\n _pusherBGMStartHandler(event) {\n trtc.pusherBGMStartHandler(event)\n },\n _pusherBGMProgressHandler(event) {\n trtc.pusherBGMProgressHandler(event)\n },\n _pusherBGMCompleteHandler(event) {\n trtc.pusherBGMCompleteHandler(event)\n },\n _pusherAudioVolumeNotify(event) {\n if (!trtcCloud.isEnterRoom) {\n return\n }\n trtc.pusherAudioVolumeNotify(event)\n }\n }\n})\n"],"sourceRoot":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<view class="trtc-pusher-container">
|
|
2
|
+
<live-pusher class="trtc-pusher" url="{{pusher.url}}" mode="{{pusher.mode}}" autopush="{{pusher.autopush}}"
|
|
3
|
+
enable-camera="{{pusher.enableCamera}}" enable-mic="{{pusher.enableMic}}" muted="{{!pusher.enableMic}}"
|
|
4
|
+
enable-agc="{{pusher.enableAgc}}" enable-ans="{{pusher.enableAns}}"
|
|
5
|
+
enable-ear-monitor="{{pusher.enableEarMonitor}}" auto-focus="{{pusher.enableAutoFocus}}"
|
|
6
|
+
zoom="{{pusher.enableZoom}}" min-bitrate="{{pusher.minBitrate}}" max-bitrate="{{pusher.maxBitrate}}"
|
|
7
|
+
video-width="{{pusher.videoWidth}}" video-height="{{pusher.videoHeight}}" beauty="{{pusher.beautyLevel}}"
|
|
8
|
+
whiteness="{{pusher.whitenessLevel}}" orientation="{{pusher.videoOrientation}}" aspect="{{pusher.videoAspect}}"
|
|
9
|
+
device-position="{{pusher.frontCamera}}" remote-mirror="{{pusher.enableRemoteMirror}}"
|
|
10
|
+
local-mirror="{{pusher.localMirror}}" background-mute="{{pusher.enableBackgroundMute}}"
|
|
11
|
+
audio-quality="{{pusher.audioQuality}}" audio-volume-type="{{pusher.audioVolumeType}}"
|
|
12
|
+
audio-reverb-type="{{pusher.audioReverbType}}" waiting-image="{{pusher.waitingImage}}"
|
|
13
|
+
beauty-style="{{pusher.beautyStyle}}" fps="{{pusher.fps}}" filter="{{pusher.filter}}"
|
|
14
|
+
bindstatechange="_pusherStateChangeHandler" bindnetstatus="_pusherNetStatusHandler"
|
|
15
|
+
binderror="_pusherErrorHandler" bindbgmstart="_pusherBGMStartHandler"
|
|
16
|
+
bindbgmprogress="_pusherBGMProgressHandler" bindbgmcomplete="_pusherBGMCompleteHandler"
|
|
17
|
+
bindaudiovolumenotify="_pusherAudioVolumeNotify" />
|
|
18
|
+
<camera wx:if="{{pusher.videoPreview}}" class="trtc-camera" device-position="{{pusher.frontCamera}}"></camera>
|
|
19
|
+
</view>
|