Browse Source

[demo] - 修复错误

kevin.song 5 years ago
parent
commit
bfaf2d305b

+ 1 - 1
examples/angular/package.json

@@ -20,9 +20,9 @@
     "@angular/platform-browser": "~8.2.14",
     "@angular/platform-browser-dynamic": "~8.2.14",
     "@angular/router": "~8.2.14",
+    "classnames": "^2.2.6",
     "rxjs": "~6.4.0",
     "tslib": "^1.10.0",
-    "unique-classnames": "^1.0.6",
     "urtc-sdk": "latest",
     "zone.js": "~0.9.1"
   },

+ 8 - 3
examples/angular/src/components/stream-info/index.ts

@@ -7,10 +7,15 @@ import {
   Input,
   SimpleChanges,
 } from '@angular/core';
-import classnames from 'unique-classnames';
+import classnames from 'classnames';
 
-import { Client } from 'urtc-sdk';
-import { Stream, AudioStats, VideoStats, NetworkStats } from 'urtc-sdk/types';
+import {
+  Client,
+  Stream,
+  AudioStats,
+  VideoStats,
+  NetworkStats
+} from 'urtc-sdk';
 
 interface Stats {
   audioLost: number;

+ 18 - 4
examples/angular/src/pages/room/index.ts

@@ -6,8 +6,10 @@ import {
   OnDestroy,
 } from '@angular/core';
 
-import sdk, { Client } from 'urtc-sdk';
-import { Stream } from 'urtc-sdk/types';
+import sdk, {
+  Client,
+  Stream
+} from 'urtc-sdk';
 
 // 注:实际使用时,请自行在 config 目录下创建 index.ts 配置文件
 import config from '../../config';
@@ -71,6 +73,10 @@ export class RoomComponent implements OnInit, AfterContentInit, AfterViewInit, O
         this.client.play({
           streamId: localStream.sid,
           container: localStream.sid
+        }, (err?: Error) => {
+          if (err) {
+            console.log('play error ', err);
+          }
         });
       }, 0);
     });
@@ -94,6 +100,10 @@ export class RoomComponent implements OnInit, AfterContentInit, AfterViewInit, O
         this.client.play({
           streamId: remoteStream.sid,
           container: remoteStream.sid
+        }, (err?: Error) => {
+          if (err) {
+            console.log('play error ', err);
+          }
         });
       }, 0);
     });
@@ -120,6 +130,10 @@ export class RoomComponent implements OnInit, AfterContentInit, AfterViewInit, O
         this.client.play({
           streamId: current.sid,
           container: current.sid
+        }, (err?: Error) => {
+          if (err) {
+            console.log('play error ', err);
+          }
         });
       }, 0);
     });
@@ -155,7 +169,7 @@ export class RoomComponent implements OnInit, AfterContentInit, AfterViewInit, O
     });
   }
   handlePublish() {
-    this.client.publish(err => {
+    this.client.publish({audio: true, video: true, screen: false}, err => {
       console.error(`发布失败:错误码 - ${err.name},错误信息 - ${err.message}`);
     });
   }
@@ -214,7 +228,7 @@ export class RoomComponent implements OnInit, AfterContentInit, AfterViewInit, O
     if (!isJoinedRoom) {
       return;
     }
-    this.client.leaveRoom(() => {
+    this.client.leaveRoom(undefined, () => {
       console.info('离开房间成功');
       this.selectedStream = null;
       this.localStreams = [];

+ 2 - 1
examples/react/package.json

@@ -3,9 +3,9 @@
   "version": "1.0.0",
   "description": "UCloud RTC react 版本的 demo",
   "dependencies": {
+    "classnames": "^2.2.6",
     "react": "^16.12.0",
     "react-dom": "^16.12.0",
-    "unique-classnames": "^1.0.6",
     "urtc-sdk": "latest"
   },
   "scripts": {
@@ -31,6 +31,7 @@
     ]
   },
   "devDependencies": {
+    "@babel/helper-call-delegate": "^7.11.4",
     "@testing-library/jest-dom": "^4.2.4",
     "@testing-library/react": "^9.3.2",
     "@testing-library/user-event": "^7.1.2",

+ 1 - 1
examples/react/src/components/StreamInfo/index.jsx

@@ -1,6 +1,6 @@
 import React, { Component, Fragment } from 'react';
 import PropTypes from 'prop-types';
-import classnames from 'unique-classnames';
+import classnames from 'classnames';
 
 export default class StreamInfo extends Component {
   static propTypes = {