新增功能
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"plugins": [
|
||||
["module-resolver", {
|
||||
"root": ["./src"],
|
||||
"alias": {}
|
||||
}]
|
||||
],
|
||||
"presets": [
|
||||
["env", {"loose": true, "modules": "commonjs"}]
|
||||
]
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
module.exports = {
|
||||
'extends': [
|
||||
'airbnb-base',
|
||||
'plugin:promise/recommended'
|
||||
],
|
||||
'parser': '@typescript-eslint/parser',
|
||||
'plugins': ['@typescript-eslint'],
|
||||
'parserOptions': {
|
||||
'ecmaVersion': 9,
|
||||
'ecmaFeatures': {
|
||||
'jsx': false
|
||||
},
|
||||
'sourceType': 'module'
|
||||
},
|
||||
'env': {
|
||||
'es6': true,
|
||||
'node': true,
|
||||
'jest': true
|
||||
},
|
||||
'plugins': [
|
||||
'import',
|
||||
'node',
|
||||
'promise'
|
||||
],
|
||||
'rules': {
|
||||
'arrow-parens': 'off',
|
||||
'comma-dangle': [
|
||||
'error',
|
||||
'only-multiline'
|
||||
],
|
||||
'complexity': ['error', 20],
|
||||
'func-names': 'off',
|
||||
'global-require': 'off',
|
||||
'handle-callback-err': [
|
||||
'error',
|
||||
'^(err|error)$'
|
||||
],
|
||||
'import/no-unresolved': [
|
||||
'error',
|
||||
{
|
||||
'caseSensitive': true,
|
||||
'commonjs': true,
|
||||
'ignore': ['^[^.]']
|
||||
}
|
||||
],
|
||||
'import/prefer-default-export': 'off',
|
||||
'linebreak-style': 'off',
|
||||
'no-catch-shadow': 'error',
|
||||
'no-continue': 'off',
|
||||
'no-div-regex': 'warn',
|
||||
'no-else-return': 'off',
|
||||
'no-param-reassign': 'off',
|
||||
'no-plusplus': 'off',
|
||||
'no-shadow': 'off',
|
||||
'no-multi-assign': 'off',
|
||||
'no-underscore-dangle': 'off',
|
||||
'node/no-deprecated-api': 'error',
|
||||
'node/process-exit-as-throw': 'error',
|
||||
'object-curly-spacing': [
|
||||
'error',
|
||||
'never'
|
||||
],
|
||||
'operator-linebreak': [
|
||||
'error',
|
||||
'after',
|
||||
{
|
||||
'overrides': {
|
||||
':': 'before',
|
||||
'?': 'before'
|
||||
}
|
||||
}
|
||||
],
|
||||
'prefer-arrow-callback': 'off',
|
||||
'prefer-destructuring': 'off',
|
||||
'prefer-template': 'off',
|
||||
'quote-props': [
|
||||
1,
|
||||
'as-needed',
|
||||
{
|
||||
'unnecessary': true
|
||||
}
|
||||
],
|
||||
'semi': [
|
||||
'error',
|
||||
'never'
|
||||
],
|
||||
'no-await-in-loop': 'off',
|
||||
'no-restricted-syntax': 'off',
|
||||
'promise/always-return': 'off',
|
||||
},
|
||||
'globals': {
|
||||
'window': true,
|
||||
'document': true,
|
||||
'App': true,
|
||||
'Page': true,
|
||||
'Component': true,
|
||||
'Behavior': true,
|
||||
'wx': true,
|
||||
'getCurrentPages': true,
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
## 2024.12.03@1.0.3
|
||||
|
||||
**Feature**
|
||||
- 升级 [@tencentcloud/trtc-cloud-wx](https://www.npmjs.com/package/@tencentcloud/trtc-cloud-wx) 到 v1.0.2 版本。
|
||||
|
||||
**Fix**
|
||||
- 修复 live-pusher 不销毁 exitRoom 无法再次进房 bug
|
||||
|
||||
## 2024.12.03@1.0.3
|
||||
|
||||
**Feature**
|
||||
- 升级 [@tencentcloud/trtc-cloud-wx](https://www.npmjs.com/package/@tencentcloud/trtc-cloud-wx) 到 v1.0.1 版本。
|
||||
|
||||
**Fix**
|
||||
- 修复 switchCamera 多次调用会出现一次设置无效问题
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
# miniprogram-custom-component
|
||||
|
||||
小程序自定义组件开发模板:
|
||||
|
||||
* 支持使用 less 语法编写 wxss 文件
|
||||
* 使用 webpack 构建 js
|
||||
* 支持自定义组件单元测试
|
||||
* 支持 eslint
|
||||
* 支持多入口构建
|
||||
|
||||
## 使用
|
||||
|
||||
* 使用[命令行工具](https://github.com/wechat-miniprogram/miniprogram-cli)进行初始化
|
||||
* 直接从 github 上 clone 下来
|
||||
|
||||
## 开发
|
||||
|
||||
1. 安装依赖:
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
2. 执行命令:
|
||||
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
默认会在包根目录下生成 miniprogram\_dev 目录,src 中的源代码会被构建并生成到 miniprogram\_dev/components 目录下。如果需要监听文件变化动态构建,则可以执行命令:
|
||||
|
||||
```
|
||||
npm run watch
|
||||
```
|
||||
|
||||
> ps: 如果 minirpogram\_dev 目录下已存在小程序 demo,执行`npm run dev`则不会再将 tools 下的 demo 拷贝到此目录下。而执行`npm run watch`则会监听 tools 目录下的 demo 变动并进行拷贝。
|
||||
|
||||
3. 生成的 miniprogram\_dev 目录是一个小程序项目目录,以此目录作为小程序项目目录在开发者工具中打开即可查看自定义组件被使用的效果。
|
||||
|
||||
4. 进阶:
|
||||
|
||||
* 如果有额外的构建需求,可自行修改 tools 目录中的构建脚本。
|
||||
* 内置支持 webpack、less 语法、sourcemap 等功能,默认关闭。如若需要可以自行修改 tools/config.js 配置文件中相关配置。
|
||||
* 内置支持多入口构建,如若需要可自行调整 tools/config.js 配置文件的 entry 字段。
|
||||
* 默认开启 eslint,可自行调整规则或在 tools/config.js 中注释掉 eslint-loader 行来关闭此功能。
|
||||
|
||||
## 发布
|
||||
|
||||
> ps: 发布前得确保已经执行构建,小程序 npm 包只有构建出来的目录是真正被使用到的。
|
||||
|
||||
1. 如果还没有 npm 帐号,可以到[ npm 官网](https://www.npmjs.com/)注册一个 npm 帐号。
|
||||
2. 在本地登录 npm 帐号,在本地执行:
|
||||
|
||||
```
|
||||
npm adduser
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```
|
||||
npm login
|
||||
```
|
||||
|
||||
3. 在已完成编写的 npm 包根目录下执行:
|
||||
|
||||
```
|
||||
npm publish
|
||||
```
|
||||
|
||||
到此,npm 包就成功发布到 npm 平台了。
|
||||
|
||||
> PS:一些开发者在开发过程中可能修改过 npm 的源,所以当进行登录或发布时需要注意要将源切回 npm 的源。
|
||||
|
||||
## 目录结构
|
||||
|
||||
以下为推荐使用的目录结构,如果有必要开发者也可以自行做一些调整:
|
||||
|
||||
```
|
||||
|--miniprogram_dev // 开发环境构建目录
|
||||
|--miniprogram_dist // 生产环境构建目录
|
||||
|--src // 源码
|
||||
| |--components // 通用自定义组件
|
||||
| |--images // 图片资源
|
||||
| |
|
||||
| |--xxx.js/xxx.wxml/xxx.json/xxx.wxss // 暴露的 js 模块/自定义组件入口文件
|
||||
|
|
||||
|--test // 测试用例
|
||||
|--tools // 构建相关代码
|
||||
| |--demo // demo 小程序目录,开发环境下会被拷贝生成到 miniprogram_dev 目录中
|
||||
| |--config.js // 构建相关配置文件
|
||||
|
|
||||
|--gulpfile.js
|
||||
```
|
||||
|
||||
> PS:对外暴露的 js 模块/自定义组件请放在 src 目录下,不宜放置在过深的目录。另外新增的暴露模块需要在 tools/config.js 的 entry 字段中补充,不然不会进行构建。
|
||||
|
||||
## 测试
|
||||
|
||||
* 执行测试用例:
|
||||
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
* 执行测试用例并进入 node inspect 调试:
|
||||
|
||||
```
|
||||
npm run test-debug
|
||||
```
|
||||
|
||||
* 检测覆盖率:
|
||||
|
||||
```
|
||||
npm run coverage
|
||||
```
|
||||
|
||||
测试用例放在 test 目录下,使用 **miniprogram-simulate** 工具集进行测试,[点击此处查看](https://github.com/wechat-miniprogram/miniprogram-simulate/blob/master/README.md)使用方法。在测试中可能需要变更或调整工具集中的一些方法,可在 test/utils 下自行实现。
|
||||
|
||||
## 其他命令
|
||||
|
||||
* 清空 miniprogram_dist 目录:
|
||||
|
||||
```
|
||||
npm run clean
|
||||
```
|
||||
|
||||
* 清空 miniprogam_dev 目录:
|
||||
|
||||
```
|
||||
npm run clean-dev
|
||||
```
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const sourceDir = '/Users/connor/Desktop/work/TRTCCloud-wx/trtc-component-wx/miniprogram_dist'
|
||||
const targetDir = '/Users/connor/Desktop/TUIRoomEngine/samples/tui-room-uniapp/dist/dev/mp-weixin/node_modules/@tencentcloud/trtc-component-wx/miniprogram_dist'
|
||||
|
||||
fs.readdir(sourceDir, (err, files) => {
|
||||
if (err) throw err
|
||||
|
||||
files.forEach((file) => {
|
||||
const sourceFile = path.join(sourceDir, file)
|
||||
const targetFile = path.join(targetDir, file)
|
||||
|
||||
fs.copyFile(sourceFile, targetFile, (err) => {
|
||||
if (err) throw err
|
||||
console.log(`${sourceFile} was copied to ${targetFile}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
const gulp = require('gulp')
|
||||
const clean = require('gulp-clean')
|
||||
|
||||
const config = require('./tools/config')
|
||||
const BuildTask = require('./tools/build')
|
||||
const id = require('./package.json').name || 'miniprogram-custom-component'
|
||||
|
||||
// 构建任务实例
|
||||
// eslint-disable-next-line no-new
|
||||
new BuildTask(id, config.entry)
|
||||
|
||||
// 清空生成目录和文件
|
||||
gulp.task('clean', gulp.series(() => gulp.src(config.distPath, {read: false, allowEmpty: true}).pipe(clean()), done => {
|
||||
if (config.isDev) {
|
||||
return gulp.src(config.demoDist, {read: false, allowEmpty: true})
|
||||
.pipe(clean())
|
||||
}
|
||||
|
||||
return done()
|
||||
}))
|
||||
// 监听文件变化并进行开发模式构建
|
||||
gulp.task('watch', gulp.series(`${id}-watch`))
|
||||
// 开发模式构建
|
||||
gulp.task('dev', gulp.series(`${id}-dev`))
|
||||
// 生产模式构建
|
||||
gulp.task('default', gulp.series(`${id}-default`))
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
module.exports =
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("@tencentcloud/trtc-cloud-wx");
|
||||
|
||||
/***/ }),
|
||||
/* 1 */,
|
||||
/* 2 */,
|
||||
/* 3 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _trtcCloudWx = __webpack_require__(0);
|
||||
|
||||
Object.keys(_trtcCloudWx).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _trtcCloudWx[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _trtcCloudWx2 = _interopRequireDefault(_trtcCloudWx);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = _trtcCloudWx2.default;
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"@tencentcloud/trtc-cloud-wx\"","webpack:///./src/index.js"],"names":["TRTCCloud"],"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,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,wD;;;;;;;;;;;;;ACAA;;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;kBACeA,qB","file":"index.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","module.exports = require(\"@tencentcloud/trtc-cloud-wx\");","import TRTCCloud from '@tencentcloud/trtc-cloud-wx'\n\nexport * from '@tencentcloud/trtc-cloud-wx'\nexport default TRTCCloud\n"],"sourceRoot":""}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
module.exports =
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 2);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("@tencentcloud/trtc-cloud-wx");
|
||||
|
||||
/***/ }),
|
||||
/* 1 */,
|
||||
/* 2 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var _trtcCloudWx = __webpack_require__(0);
|
||||
|
||||
var _trtcCloudWx2 = _interopRequireDefault(_trtcCloudWx);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var trtcCloud = _trtcCloudWx2.default.getTRTCShareInstance();
|
||||
var trtc = trtcCloud.trtc;
|
||||
var InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
streamId: String
|
||||
},
|
||||
data: {
|
||||
player: {},
|
||||
TRTCStreamId: '',
|
||||
soundMode: ''
|
||||
},
|
||||
lifetimes: {
|
||||
attached: function attached() {
|
||||
trtcCloud.logger.info('trtc-player attached', this.data.streamId);
|
||||
if (this.data.streamId) {
|
||||
InterfaceEventEmitter.emit('playerDomReady', { isReady: true, view: this.data.streamId });
|
||||
}
|
||||
this.data.TRTCStreamId = this.getTRTCStreamId(this.data.streamId);
|
||||
this.bindTRTCCloudEvent();
|
||||
},
|
||||
detached: function detached() {
|
||||
trtcCloud.logger.info('trtc-player detached', this.data.streamId);
|
||||
InterfaceEventEmitter.emit('playerDomReady', { isReady: false, streamId: this.data.streamId });
|
||||
this.unbindTRTCCloudEvent();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// todo room uniapp 特供,因为 uniapp 打包导致组件传惨变量名更替 trtc-player 组建内部无法识别
|
||||
setTRTCStreamId: function setTRTCStreamId(id) {
|
||||
var _this = this;
|
||||
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId', id);
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
_this.data.streamId = id;
|
||||
_this.data.TRTCStreamId = _this.getTRTCStreamId(id);
|
||||
_this.setData({ streamId: _this.data.streamId }, function () {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId success', id);
|
||||
resolve();
|
||||
InterfaceEventEmitter.emit('playerDomReady', { isReady: true, view: id });
|
||||
});
|
||||
} catch (err) {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId fail', id, err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
playerAttributesChange: function playerAttributesChange(event) {
|
||||
var view = event.view,
|
||||
playerAttributes = event.playerAttributes,
|
||||
callback = event.callback;
|
||||
|
||||
trtcCloud.logger.info('trtc-player playerAttributesChange', view, JSON.stringify(playerAttributes), this.data.streamId);
|
||||
if (view === this.data.streamId) {
|
||||
this.setData({ player: playerAttributes }, callback);
|
||||
}
|
||||
},
|
||||
playerAudioRouteChange: function playerAudioRouteChange(event) {
|
||||
var soundMode = event.soundMode,
|
||||
callback = event.callback;
|
||||
|
||||
trtcCloud.logger.info('trtc-player playerAudioRouteChange', soundMode);
|
||||
this.setData({ soundMode: soundMode }, callback);
|
||||
},
|
||||
getTRTCStreamId: function getTRTCStreamId(streamId) {
|
||||
var tempArray = streamId.split('_');
|
||||
var userId = tempArray.slice(0, -1).join('_');
|
||||
var streamType = Number(tempArray[tempArray.length - 1]);
|
||||
return (0, _trtcCloudWx.translateTRTCStreamId)(userId, streamType);
|
||||
},
|
||||
bindTRTCCloudEvent: function bindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.on('playerAttributesChange', this.playerAttributesChange, this);
|
||||
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange, this);
|
||||
},
|
||||
unbindTRTCCloudEvent: function unbindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.off('playerAttributesChange', this.playerAttributesChange);
|
||||
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange);
|
||||
},
|
||||
|
||||
// 请保持跟 wxml 中绑定的事件名称一致
|
||||
_playerStateChange: function _playerStateChange(event) {
|
||||
trtc.playerEventHandler(event);
|
||||
},
|
||||
_playerFullscreenChange: function _playerFullscreenChange(event) {
|
||||
trtc.playerFullscreenChange(event);
|
||||
},
|
||||
_playerNetStatus: function _playerNetStatus(event) {
|
||||
trtc.playerNetStatus(event);
|
||||
},
|
||||
_playerAudioVolumeNotify: function _playerAudioVolumeNotify(event) {
|
||||
try {
|
||||
event.currentTarget.dataset.streamid = this.data.player.streamID;
|
||||
trtc.playerAudioVolumeNotify(event);
|
||||
} catch (err) {
|
||||
trtcCloud.logger.warn(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
//# sourceMappingURL=trtc-player.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
<view class="trtc-player-container">
|
||||
<live-player wx:if="{{streamId}}" class="trtc-player" id="{{player.streamID}}" data-userid="{{player.userID}}"
|
||||
data-streamid="{{player.streamID}}" data-streamtype="{{player.streamType}}" src="{{player.src}}" mode="RTC"
|
||||
autoplay="{{player.autoplay}}" mute-audio="{{player.muteAudio}}" mute-video="{{player.muteVideo}}"
|
||||
orientation="{{player.orientation}}" object-fit="{{player.objectFit}}"
|
||||
background-mute="{{player.enableBackgroundMute}}" min-cache="{{player.minCache}}" max-cache="{{player.maxCache}}"
|
||||
sound-mode="{{soundMode}}" enable-recv-message="{{player.enableRecvMessage}}"
|
||||
auto-pause-if-navigate="{{player.autoPauseIfNavigate}}" auto-pause-if-open-native="{{player.autoPauseIfOpenNative}}"
|
||||
debug="{{player.debug}}" bindstatechange="_playerStateChange" bindfullscreenchange="_playerFullscreenChange"
|
||||
bindnetstatus="_playerNetStatus" bindaudiovolumenotify="_playerAudioVolumeNotify" />
|
||||
<view wx:if="{{player.stopVideo}}" class="trtc-dark-mask"></view>
|
||||
</view>
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
.trtc-player-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.trtc-player {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.trtc-dark-mask {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
module.exports =
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 1);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = require("@tencentcloud/trtc-cloud-wx");
|
||||
|
||||
/***/ }),
|
||||
/* 1 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var _trtcCloudWx = __webpack_require__(0);
|
||||
|
||||
var _trtcCloudWx2 = _interopRequireDefault(_trtcCloudWx);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var trtcCloud = _trtcCloudWx2.default.getTRTCShareInstance();
|
||||
var trtc = trtcCloud.trtc;
|
||||
var InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter;
|
||||
|
||||
Component({
|
||||
properties: {},
|
||||
data: {
|
||||
pusher: {}
|
||||
},
|
||||
lifetimes: {
|
||||
attached: function attached() {
|
||||
trtcCloud.logger.info('trtc-pusher attached');
|
||||
this.bindTRTCCloudEvent();
|
||||
// 注意事件绑定应该放在 domReady 之前,因为此时出发 domReady 会执行 ready 后的后续操作依赖 bindTRTCCloudEvent
|
||||
InterfaceEventEmitter.emit('pusherDomReady', true);
|
||||
},
|
||||
detached: function detached() {
|
||||
trtcCloud.logger.info('trtc-pusher detached');
|
||||
InterfaceEventEmitter.emit('pusherDomReady', false);
|
||||
this.unbindTRTCCloudEvent();
|
||||
trtcCloud.exitRoom();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
pusherAttributesChange: function pusherAttributesChange(event) {
|
||||
var pusher = event.pusher,
|
||||
callback = event.callback;
|
||||
|
||||
this.setData({ pusher: pusher }, callback);
|
||||
},
|
||||
playerAudioRouteChange: function playerAudioRouteChange(event) {
|
||||
var soundMode = event.soundMode,
|
||||
callback = event.callback;
|
||||
|
||||
trtcCloud.logger.info('trtc-player playerAudioRouteChange', soundMode);
|
||||
this.setData({ soundMode: soundMode }, callback);
|
||||
},
|
||||
bindTRTCCloudEvent: function bindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.on('pusherAttributesChange', this.pusherAttributesChange, this);
|
||||
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange, this);
|
||||
},
|
||||
unbindTRTCCloudEvent: function unbindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.off('pusherAttributesChange', this.pusherAttributesChange);
|
||||
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange);
|
||||
},
|
||||
|
||||
// 请保持跟 wxml 中绑定的事件名称一致
|
||||
_pusherStateChangeHandler: function _pusherStateChangeHandler(event) {
|
||||
trtc.pusherEventHandler(event);
|
||||
},
|
||||
_pusherNetStatusHandler: function _pusherNetStatusHandler(event) {
|
||||
trtc.pusherNetStatusHandler(event);
|
||||
},
|
||||
_pusherErrorHandler: function _pusherErrorHandler(event) {
|
||||
trtc.pusherErrorHandler(event);
|
||||
},
|
||||
_pusherBGMStartHandler: function _pusherBGMStartHandler(event) {
|
||||
trtc.pusherBGMStartHandler(event);
|
||||
},
|
||||
_pusherBGMProgressHandler: function _pusherBGMProgressHandler(event) {
|
||||
trtc.pusherBGMProgressHandler(event);
|
||||
},
|
||||
_pusherBGMCompleteHandler: function _pusherBGMCompleteHandler(event) {
|
||||
trtc.pusherBGMCompleteHandler(event);
|
||||
},
|
||||
_pusherAudioVolumeNotify: function _pusherAudioVolumeNotify(event) {
|
||||
if (!trtcCloud.isEnterRoom) {
|
||||
return;
|
||||
}
|
||||
trtc.pusherAudioVolumeNotify(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/***/ })
|
||||
/******/ ]);
|
||||
//# sourceMappingURL=trtc-pusher.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
<view class="trtc-pusher-container">
|
||||
<live-pusher class="trtc-pusher" url="{{pusher.url}}" mode="{{'HD'}}" autopush="{{pusher.autopush}}"
|
||||
enable-camera="{{pusher.enableCamera}}" enable-mic="{{pusher.enableMic}}" muted="{{pusher.muted}}"
|
||||
enable-agc="{{pusher.enableAgc}}" enable-ans="{{pusher.enableAns}}"
|
||||
enable-ear-monitor="{{pusher.enableEarMonitor}}" auto-focus="{{pusher.enableAutoFocus}}"
|
||||
zoom="{{pusher.enableZoom}}" min-bitrate="{{pusher.minBitrate}}" max-bitrate="{{pusher.maxBitrate}}"
|
||||
video-width="{{pusher.videoWidth}}" video-height="{{pusher.videoHeight}}" beauty="{{pusher.beautyLevel}}"
|
||||
whiteness="{{pusher.whitenessLevel}}" orientation="{{pusher.videoOrientation}}" aspect="{{pusher.videoAspect}}"
|
||||
device-position="{{pusher.frontCamera}}" remote-mirror="{{pusher.enableRemoteMirror}}"
|
||||
local-mirror="{{pusher.localMirror}}" background-mute="{{pusher.enableBackgroundMute}}"
|
||||
audio-quality="{{pusher.audioQuality}}" audio-volume-type="{{pusher.audioVolumeType}}"
|
||||
audio-reverb-type="{{pusher.audioReverbType}}" waiting-image="{{pusher.waitingImage}}"
|
||||
beauty-style="{{pusher.beautyStyle}}" fps="{{pusher.fps}}" filter="{{pusher.filter}}"
|
||||
audio-quality="{{pusher.audioQuality}}"
|
||||
bindstatechange="_pusherStateChangeHandler" bindnetstatus="_pusherNetStatusHandler"
|
||||
binderror="_pusherErrorHandler" bindbgmstart="_pusherBGMStartHandler"
|
||||
bindbgmprogress="_pusherBGMProgressHandler" bindbgmcomplete="_pusherBGMCompleteHandler"
|
||||
bindaudiovolumenotify="_pusherAudioVolumeNotify" />
|
||||
<live-player class="trtc-player" sound-mode="{{soundMode}}">
|
||||
</live-player>
|
||||
<!-- <camera wx:if="{{pusher.videoPreview}}" class="trtc-camera" device-position="{{pusher.frontCamera}}"></camera> -->
|
||||
</view>
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
.trtc-pusher-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.trtc-pusher {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.trtc-camera {
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
.trtc-player {
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: flex;
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "@tencentcloud/trtc-component-wx",
|
||||
"version": "1.0.6",
|
||||
"description": "",
|
||||
"main": "miniprogram_dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "gulp dev --develop",
|
||||
"watch": "gulp watch --develop --watch",
|
||||
"build": "gulp",
|
||||
"dist": "npm run build",
|
||||
"clean-dev": "gulp clean --develop",
|
||||
"clean": "gulp clean",
|
||||
"test": "jest --bail",
|
||||
"test-debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --bail",
|
||||
"coverage": "jest ./test/* --coverage --bail",
|
||||
"lint": "eslint \"src/**/*.js\" --fix",
|
||||
"lint-tools": "eslint \"tools/**/*.js\" --rule \"import/no-extraneous-dependencies: false\" --fix"
|
||||
},
|
||||
"miniprogram": "miniprogram_dist",
|
||||
"jest": {
|
||||
"testEnvironment": "jsdom",
|
||||
"testURL": "https://jest.test",
|
||||
"collectCoverageFrom": [
|
||||
"miniprogram_dist/**/*.js"
|
||||
],
|
||||
"moduleDirectories": [
|
||||
"node_modules",
|
||||
"miniprogram_dist"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": ""
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^2.28.0",
|
||||
"@typescript-eslint/parser": "^2.28.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-loader": "^7.1.5",
|
||||
"babel-plugin-module-resolver": "^3.2.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"colors": "^1.3.1",
|
||||
"eslint": "^5.14.1",
|
||||
"eslint-config-airbnb-base": "13.1.0",
|
||||
"eslint-loader": "^2.1.2",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
"eslint-plugin-node": "^7.0.1",
|
||||
"eslint-plugin-promise": "^3.8.0",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-if": "^2.0.2",
|
||||
"gulp-install": "^1.1.0",
|
||||
"gulp-less": "^4.0.1",
|
||||
"gulp-rename": "^1.4.0",
|
||||
"gulp-sourcemaps": "^2.6.5",
|
||||
"jest": "^23.5.0",
|
||||
"miniprogram-api-typings": "^2.10.3-1",
|
||||
"miniprogram-simulate": "^1.2.5",
|
||||
"thread-loader": "^2.1.3",
|
||||
"through2": "^2.0.3",
|
||||
"ts-loader": "^7.0.0",
|
||||
"typescript": "^3.8.3",
|
||||
"vinyl": "^2.2.0",
|
||||
"webpack": "^4.29.5",
|
||||
"webpack-node-externals": "^1.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tencentcloud/trtc-cloud-wx": "^1.0.7"
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import TRTCCloud from '@tencentcloud/trtc-cloud-wx'
|
||||
|
||||
export * from '@tencentcloud/trtc-cloud-wx'
|
||||
export default TRTCCloud
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
import TRTCCloud, {translateTRTCStreamId} from '@tencentcloud/trtc-cloud-wx'
|
||||
|
||||
const trtcCloud = TRTCCloud.getTRTCShareInstance()
|
||||
const trtc = trtcCloud.trtc
|
||||
const InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
streamId: String
|
||||
},
|
||||
data: {
|
||||
player: {},
|
||||
TRTCStreamId: '',
|
||||
soundMode: ''
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
trtcCloud.logger.info('trtc-player attached', this.data.streamId)
|
||||
if (this.data.streamId) {
|
||||
InterfaceEventEmitter.emit('playerDomReady', {isReady: true, view: this.data.streamId})
|
||||
}
|
||||
this.data.TRTCStreamId = this.getTRTCStreamId(this.data.streamId)
|
||||
this.bindTRTCCloudEvent()
|
||||
},
|
||||
detached() {
|
||||
trtcCloud.logger.info('trtc-player detached', this.data.streamId)
|
||||
InterfaceEventEmitter.emit('playerDomReady', {isReady: false, streamId: this.data.streamId})
|
||||
this.unbindTRTCCloudEvent()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// todo room uniapp 特供,因为 uniapp 打包导致组件传惨变量名更替 trtc-player 组建内部无法识别
|
||||
setTRTCStreamId(id) {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId', id)
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
this.data.streamId = id
|
||||
this.data.TRTCStreamId = this.getTRTCStreamId(id)
|
||||
this.setData({streamId: this.data.streamId}, () => {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId success', id)
|
||||
resolve()
|
||||
InterfaceEventEmitter.emit('playerDomReady', {isReady: true, view: id})
|
||||
})
|
||||
} catch (err) {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId fail', id, err)
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
playerAttributesChange(event) {
|
||||
const {view, playerAttributes, callback} = event
|
||||
trtcCloud.logger.info('trtc-player playerAttributesChange', view, JSON.stringify(playerAttributes), this.data.streamId)
|
||||
if (view === this.data.streamId) {
|
||||
this.setData({player: playerAttributes}, callback)
|
||||
}
|
||||
},
|
||||
playerAudioRouteChange(event) {
|
||||
const { soundMode, callback } = event
|
||||
trtcCloud.logger.info('trtc-player playerAudioRouteChange', soundMode)
|
||||
this.setData({ soundMode }, callback)
|
||||
},
|
||||
getTRTCStreamId(streamId) {
|
||||
const tempArray = streamId.split('_')
|
||||
const userId = tempArray.slice(0, -1).join('_')
|
||||
const streamType = Number(tempArray[tempArray.length - 1])
|
||||
return translateTRTCStreamId(userId, streamType)
|
||||
},
|
||||
bindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.on('playerAttributesChange', this.playerAttributesChange, this)
|
||||
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange, this)
|
||||
},
|
||||
unbindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.off('playerAttributesChange', this.playerAttributesChange)
|
||||
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange)
|
||||
},
|
||||
// 请保持跟 wxml 中绑定的事件名称一致
|
||||
_playerStateChange(event) {
|
||||
trtc.playerEventHandler(event)
|
||||
},
|
||||
_playerFullscreenChange(event) {
|
||||
trtc.playerFullscreenChange(event)
|
||||
},
|
||||
_playerNetStatus(event) {
|
||||
trtc.playerNetStatus(event)
|
||||
},
|
||||
_playerAudioVolumeNotify(event) {
|
||||
try {
|
||||
event.currentTarget.dataset.streamid = this.data.player.streamID
|
||||
trtc.playerAudioVolumeNotify(event)
|
||||
} catch (err) {
|
||||
trtcCloud.logger.warn(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<view class="trtc-player-container">
|
||||
<live-player wx:if="{{streamId}}" class="trtc-player" id="{{player.streamID}}" data-userid="{{player.userID}}"
|
||||
data-streamid="{{player.streamID}}" data-streamtype="{{player.streamType}}" src="{{player.src}}" mode="RTC"
|
||||
autoplay="{{player.autoplay}}" mute-audio="{{player.muteAudio}}" mute-video="{{player.muteVideo}}"
|
||||
orientation="{{player.orientation}}" object-fit="{{player.objectFit}}"
|
||||
background-mute="{{player.enableBackgroundMute}}" min-cache="{{player.minCache}}" max-cache="{{player.maxCache}}"
|
||||
sound-mode="{{soundMode}}" enable-recv-message="{{player.enableRecvMessage}}"
|
||||
auto-pause-if-navigate="{{player.autoPauseIfNavigate}}" auto-pause-if-open-native="{{player.autoPauseIfOpenNative}}"
|
||||
debug="{{player.debug}}" bindstatechange="_playerStateChange" bindfullscreenchange="_playerFullscreenChange"
|
||||
bindnetstatus="_playerNetStatus" bindaudiovolumenotify="_playerAudioVolumeNotify" />
|
||||
<view wx:if="{{player.stopVideo}}" class="trtc-dark-mask"></view>
|
||||
</view>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
.trtc-player-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.trtc-player {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.trtc-dark-mask {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
import TRTCCloud from '@tencentcloud/trtc-cloud-wx'
|
||||
|
||||
const trtcCloud = TRTCCloud.getTRTCShareInstance()
|
||||
const trtc = trtcCloud.trtc
|
||||
const InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
},
|
||||
data: {
|
||||
pusher: {},
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
trtcCloud.logger.info('trtc-pusher attached')
|
||||
this.bindTRTCCloudEvent()
|
||||
// 注意事件绑定应该放在 domReady 之前,因为此时出发 domReady 会执行 ready 后的后续操作依赖 bindTRTCCloudEvent
|
||||
InterfaceEventEmitter.emit('pusherDomReady', true)
|
||||
},
|
||||
detached() {
|
||||
trtcCloud.logger.info('trtc-pusher detached')
|
||||
InterfaceEventEmitter.emit('pusherDomReady', false)
|
||||
this.unbindTRTCCloudEvent()
|
||||
trtcCloud.exitRoom()
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
methods: {
|
||||
pusherAttributesChange(event) {
|
||||
const {pusher, callback} = event
|
||||
this.setData({pusher}, callback)
|
||||
},
|
||||
playerAudioRouteChange(event) {
|
||||
const { soundMode, callback } = event
|
||||
trtcCloud.logger.info('trtc-player playerAudioRouteChange', soundMode)
|
||||
this.setData({ soundMode }, callback)
|
||||
},
|
||||
bindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.on('pusherAttributesChange', this.pusherAttributesChange, this)
|
||||
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange, this)
|
||||
},
|
||||
unbindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.off('pusherAttributesChange', this.pusherAttributesChange)
|
||||
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange)
|
||||
},
|
||||
// 请保持跟 wxml 中绑定的事件名称一致
|
||||
_pusherStateChangeHandler(event) {
|
||||
trtc.pusherEventHandler(event)
|
||||
},
|
||||
_pusherNetStatusHandler(event) {
|
||||
trtc.pusherNetStatusHandler(event)
|
||||
},
|
||||
_pusherErrorHandler(event) {
|
||||
trtc.pusherErrorHandler(event)
|
||||
},
|
||||
_pusherBGMStartHandler(event) {
|
||||
trtc.pusherBGMStartHandler(event)
|
||||
},
|
||||
_pusherBGMProgressHandler(event) {
|
||||
trtc.pusherBGMProgressHandler(event)
|
||||
},
|
||||
_pusherBGMCompleteHandler(event) {
|
||||
trtc.pusherBGMCompleteHandler(event)
|
||||
},
|
||||
_pusherAudioVolumeNotify(event) {
|
||||
if (!trtcCloud.isEnterRoom) {
|
||||
return
|
||||
}
|
||||
trtc.pusherAudioVolumeNotify(event)
|
||||
}
|
||||
}
|
||||
})
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<view class="trtc-pusher-container">
|
||||
<live-pusher class="trtc-pusher" url="{{pusher.url}}" mode="{{'HD'}}" autopush="{{pusher.autopush}}"
|
||||
enable-camera="{{pusher.enableCamera}}" enable-mic="{{pusher.enableMic}}" muted="{{pusher.muted}}"
|
||||
enable-agc="{{pusher.enableAgc}}" enable-ans="{{pusher.enableAns}}"
|
||||
enable-ear-monitor="{{pusher.enableEarMonitor}}" auto-focus="{{pusher.enableAutoFocus}}"
|
||||
zoom="{{pusher.enableZoom}}" min-bitrate="{{pusher.minBitrate}}" max-bitrate="{{pusher.maxBitrate}}"
|
||||
video-width="{{pusher.videoWidth}}" video-height="{{pusher.videoHeight}}" beauty="{{pusher.beautyLevel}}"
|
||||
whiteness="{{pusher.whitenessLevel}}" orientation="{{pusher.videoOrientation}}" aspect="{{pusher.videoAspect}}"
|
||||
device-position="{{pusher.frontCamera}}" remote-mirror="{{pusher.enableRemoteMirror}}"
|
||||
local-mirror="{{pusher.localMirror}}" background-mute="{{pusher.enableBackgroundMute}}"
|
||||
audio-quality="{{pusher.audioQuality}}" audio-volume-type="{{pusher.audioVolumeType}}"
|
||||
audio-reverb-type="{{pusher.audioReverbType}}" waiting-image="{{pusher.waitingImage}}"
|
||||
beauty-style="{{pusher.beautyStyle}}" fps="{{pusher.fps}}" filter="{{pusher.filter}}"
|
||||
audio-quality="{{pusher.audioQuality}}"
|
||||
bindstatechange="_pusherStateChangeHandler" bindnetstatus="_pusherNetStatusHandler"
|
||||
binderror="_pusherErrorHandler" bindbgmstart="_pusherBGMStartHandler"
|
||||
bindbgmprogress="_pusherBGMProgressHandler" bindbgmcomplete="_pusherBGMCompleteHandler"
|
||||
bindaudiovolumenotify="_pusherAudioVolumeNotify" />
|
||||
<live-player class="trtc-player" sound-mode="{{soundMode}}">
|
||||
</live-player>
|
||||
<!-- <camera wx:if="{{pusher.videoPreview}}" class="trtc-camera" device-position="{{pusher.frontCamera}}"></camera> -->
|
||||
</view>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
.trtc-pusher-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.trtc-pusher {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.trtc-camera {
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
.trtc-player {
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: flex;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"target": "es2015",
|
||||
"lib": ["es2015", "es2017", "dom"],
|
||||
"noImplicitAny": false,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata":true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"files": [
|
||||
"node_modules/miniprogram-api-typings/index.d.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user