edu-trct.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import TRTC from "../utils/trtc-wx";
  2. class EduTRTC {
  3. static instance = null
  4. _SDKInstance = null
  5. page = null
  6. static getInstance() {
  7. if (!EduTRTC.instance) {
  8. EduTRTC.instance = new EduTRTC();
  9. }
  10. return EduTRTC.instance;
  11. }
  12. initPage(page) {
  13. this.page = page;
  14. }
  15. getSDK() {
  16. if (this._SDKInstance == null) {
  17. if (this.page == null) {
  18. throw new Error("TRTC未初始化")
  19. }
  20. let obj = new TRTC(this.page);
  21. this._SDKInstance = obj;
  22. }
  23. return this._SDKInstance;
  24. }
  25. createPusher(page) {
  26. return this.getSDK().createPusher({
  27. beautyLevel: 9,
  28. mode: 'live',
  29. }).pusherAttributes;
  30. }
  31. exitRoom(page) {
  32. const result = this.getSDK().exitRoom();
  33. page = null;
  34. this._SDKInstance = null;
  35. return result;
  36. }
  37. getPlayerList(){
  38. return this.getSDK().getPlayerList()
  39. }
  40. }
  41. export default EduTRTC;