tendenceImSdk.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const IMSDK = {
  2. $api: null,
  3. init(){
  4. this.$api = uni.requireNativePlugin('Html5App-TencentCall');
  5. return this;
  6. },
  7. joinRoom(param,cb) { //加入/创建房间
  8. if(!this.$api)this.init();
  9. this.$api.joinRoom({
  10. "userid": param.userid,
  11. "roomid": param.roomid,
  12. "usersig": param.usersig
  13. }, ret => {
  14. if(cb)cb();
  15. })
  16. },
  17. exitRoom(cb){ //离开房间
  18. if(!this.$api)this.init();
  19. this.$api.exitRoom()
  20. if(cb)cb()
  21. },
  22. removeUser(userid,cb){ //踢出房间
  23. if(!this.$api)this.init();
  24. this.$api.removeUser({"userid":userid},ret=>{
  25. if(cb)cb();
  26. });
  27. },
  28. muteLocalAudio(mute,cb){ //设置本地音频是否开启,
  29. if(!this.$api)this.init();
  30. this.$api.muteLocalAudio({mute:mute},ret=>{
  31. if(cb)cb();
  32. });
  33. },
  34. setAudioRoute($route,cb){ //设置切换音频通道 //0=>代表扬声器,1=> 听筒
  35. if(!this.$api)this.init();
  36. this.$api.setAudioRoute({route:$route},ret=> {
  37. if(cb)cb();
  38. });
  39. },
  40. muteRemoteAudio(userid,mute,cb){ //禁言mute : 0=>代表禁言,1=> 开启发言
  41. if(!this.$api)this.init();
  42. this.$api.muteRemoteAudio({"userid":userid,mute:mute},ret=>{
  43. if(cb)cb();
  44. });
  45. }
  46. }
  47. export default{
  48. IMSDK
  49. }