Guest User

Untitled

a guest
May 23rd, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. import React from 'react';
  2. import './App.css';
  3. import {ZoomMtg} from '@zoomus/websdk';
  4. import {Stream} from './Stream'
  5. import {MainMenu} from './MainMenu';
  6. import { Provider } from 'mobx-react';
  7. import { MainMenuStore } from './stores/MainMenuStore';
  8. import 'bootstrap/dist/css/bootstrap.css';
  9. import { Footer } from './Footer';
  10.  
  11. function App() {
  12. return (
  13. <div className="container">
  14. <Provider>
  15. <Stream/>
  16.  
  17. </Provider>
  18. </div>
  19. )
  20. }
  21.  
  22. export default App;
  23.  
  24. ___________________________________________________________
  25. import { Component } from "react";
  26. import React from "react";
  27. import {ZoomMtg} from '@zoomus/websdk';
  28. const zoomMeeting = document.getElementById("zmmtg-root")
  29.  
  30.  
  31. export class Stream extends Component<{},{meetingLaunched: boolean}> {
  32.  
  33. constructor(props) {
  34. super(props);
  35. this.state = { meetingLaunched : false};
  36. this.turnItOff();
  37. }
  38. turnItOn = () => {
  39. if (zoomMeeting != null) {
  40. zoomMeeting.style.display = 'flex'
  41. zoomMeeting.style.height = '100%'
  42. zoomMeeting.style.width = '100%'
  43. zoomMeeting.style.position = 'fixed'
  44. zoomMeeting.style.zIndex = '1'
  45. zoomMeeting.style.backgroundColor = 'blue'
  46. }
  47. }
  48.  
  49. turnItOff = () => {
  50.  
  51. if (zoomMeeting != null) {
  52.  
  53. zoomMeeting.style.display = 'none'
  54. zoomMeeting.style.height = '0px'
  55. zoomMeeting.style.width = '0px'
  56. zoomMeeting.style.position = 'relative'
  57. zoomMeeting.style.backgroundColor = 'black'
  58. zoomMeeting.style.zIndex = '1'
  59. }
  60. }
  61.  
  62. joinZoomMeeting = () => {
  63. this.setState({meetingLaunched: !this.state.meetingLaunched})
  64. console.log('checkSystemRequirements');
  65. console.log(JSON.stringify(ZoomMtg.checkSystemRequirements()));
  66. ZoomMtg.generateSignature({
  67. meetingNumber: meetConfig.meetingNumber,
  68. apiKey: meetConfig.apiKey,
  69. apiSecret: meetConfig.apiSecret,
  70. role: meetConfig.role,
  71. success(res) {
  72. console.log('signature', res.result);
  73. ZoomMtg.init({
  74. leaveUrl: meetConfig.leaveUrl,
  75. success() {
  76. console.log("Sucess")
  77. ZoomMtg.join(
  78. {
  79. meetingNumber: meetConfig.meetingNumber,
  80. userName: meetConfig.userName,
  81. signature: res.result,
  82. apiKey: meetConfig.apiKey,
  83. passWord: meetConfig.passWord,
  84. success() {
  85. console.log('join meeting success');
  86. },
  87. error(respo) {
  88. console.log(respo);
  89. }
  90. }
  91. );
  92. },
  93. error(response) {
  94. console.log(response);
  95. }
  96. });
  97. }
  98. })
  99. };
  100.  
  101. render() {
  102. if (!this.state.meetingLaunched) {
  103. this.turnItOff();
  104. } else {
  105. this.turnItOn();
  106. }
  107. console.log("Rendering.")
  108. if (zoomMeeting != null) {
  109. zoomMeeting.style.height = '500px';
  110. zoomMeeting.style.width = '200px';
  111. zoomMeeting.style.position = 'relative';
  112. zoomMeeting.style.zIndex = '1';
  113. }
  114. return (
  115. <>
  116. {!this.state.meetingLaunched ?
  117.  
  118. <button className="launchButton" onClick={this.joinZoomMeeting}>Launch Meeting</button>
  119. :
  120. <div id="zmmtg-root"></div>
  121. }
  122. </>
  123. )
  124. }
  125.  
  126. componentDidMount() {
  127. console.log("Before mounting.")
  128. setTimeout(() => {
  129. ZoomMtg.setZoomJSLib('https://source.zoom.us/1.7.7/lib', '/av');
  130. ZoomMtg.preLoadWasm();
  131. ZoomMtg.prepareJssdk();
  132. }, 6000);
  133. console.log("After mounting.")
  134. }
  135.  
  136.  
  137. }
Add Comment
Please, Sign In to add comment