Facebook
From Etibar, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 96
  1. import { Component, OnInit, Inject } from '@angular/core';
  2. import { HttpClient } from '@angular/common/http';
  3. import { DOCUMENT } from '@angular/common';
  4. import {ZoomMtg} from '@zoomus/websdk';
  5.  
  6. ZoomMtg.preLoadWasm();
  7. ZoomMtg.prepareJssdk();
  8. ZoomMtg.setZoomJSLib('https://localhost:8100/assets/js/zoom/','/av');
  9.  
  10. @Component({
  11.   selector: 'zoom',
  12.   templateUrl: 'zoom.component.html'
  13. })
  14. export class ZoomComponent implements OnInit {
  15.  
  16.   // setup your signature endpoint here: https://github.com/zoom/websdk-sample-signature-node.js
  17.   signatureEndpoint = ''
  18.   apiKey = ''
  19.   meetingNumber = '123456789'
  20.   role = 0
  21.   leaveUrl = 'http://localhost:4200'
  22.   userName = 'Angular'
  23.   userEmail = ''
  24.   passWord = ''
  25.  
  26.   constructor(public httpClient: HttpClient, @Inject(DOCUMENT) document) {
  27.  
  28.   }
  29.  
  30.   ngOnInit() {
  31.  
  32.   }
  33.  
  34.   getSignature() {
  35.     this.httpClient.post(this.signatureEndpoint, {
  36.             meetingNumber: this.meetingNumber,
  37.             role: this.role
  38.     }).toPromise().then((data: any) => {
  39.       if(data.signature) {
  40.         console.log(data.signature)
  41.         this.startMeeting(data.signature)
  42.       } else {
  43.         console.log(data)
  44.       }
  45.     }).catch((error) => {
  46.       console.log(error)
  47.     })
  48.   }
  49.  
  50.   startMeeting(signature) {
  51.  
  52.     document.getElementById('zmmtg-root').style.display = 'block'
  53.  
  54.     ZoomMtg.init({
  55.       leaveUrl: this.leaveUrl,
  56.       isSupportAV: true,
  57.       success: (success) => {
  58.         console.log(success)
  59.  
  60.         ZoomMtg.join({
  61.           signature: signature,
  62.           meetingNumber: this.meetingNumber,
  63.           userName: this.userName,
  64.           apiKey: this.apiKey,
  65.           userEmail: this.userEmail,
  66.           passWord: this.passWord,
  67.           success: (success) => {
  68.             console.log(success)
  69.           },
  70.           error: (error) => {
  71.             console.log(error)
  72.           }
  73.         })
  74.  
  75.       },
  76.       error: (error) => {
  77.         console.log(error)
  78.       }
  79.     })
  80.   }
  81. }
  82.