UNPKG

@maxverse/media-web-sdk

Version:
77 lines (74 loc) 4.93 kB
import { createClass as _createClass, classCallCheck as _classCallCheck, classPrivateFieldLooseBase as _classPrivateFieldLooseBase, asyncToGenerator as _asyncToGenerator, classPrivateFieldLooseKey as _classPrivateFieldLooseKey, regeneratorRuntime as _regeneratorRuntime } from '../_virtual/_rollupPluginBabelHelpers.mjs'; import { Track } from 'livekit-client'; var _room = /*#__PURE__*/_classPrivateFieldLooseKey("room"); var _isLocalVideoEnabled = /*#__PURE__*/_classPrivateFieldLooseKey("isLocalVideoEnabled"); var _isLocalAudioEnabled = /*#__PURE__*/_classPrivateFieldLooseKey("isLocalAudioEnabled"); var _videoDeviceId = /*#__PURE__*/_classPrivateFieldLooseKey("videoDeviceId"); var _audioDeviceId = /*#__PURE__*/_classPrivateFieldLooseKey("audioDeviceId"); var LocalTrackController = /*#__PURE__*/_createClass(function LocalTrackController(room, isVideoEnabled, isAudioEnabled, videoDeviceId, audioDeviceId) { var _this = this; _classCallCheck(this, LocalTrackController); Object.defineProperty(this, _room, { writable: true, value: void 0 }); Object.defineProperty(this, _isLocalVideoEnabled, { writable: true, value: void 0 }); Object.defineProperty(this, _isLocalAudioEnabled, { writable: true, value: void 0 }); Object.defineProperty(this, _videoDeviceId, { writable: true, value: void 0 }); Object.defineProperty(this, _audioDeviceId, { writable: true, value: void 0 }); this.toggleCam = function () { var _classPrivateFieldLoo, _classPrivateFieldLoo2; var isEnabled = (_classPrivateFieldLoo = (_classPrivateFieldLoo2 = _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.getTrack(Track.Source.Camera)) === null || _classPrivateFieldLoo2 === void 0 ? void 0 : _classPrivateFieldLoo2.isMuted) !== null && _classPrivateFieldLoo !== void 0 ? _classPrivateFieldLoo : true; _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.setCameraEnabled(isEnabled); }; this.toggleMic = function () { var _classPrivateFieldLoo3, _classPrivateFieldLoo4; var isEnabled = (_classPrivateFieldLoo3 = (_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.getTrack(Track.Source.Microphone)) === null || _classPrivateFieldLoo4 === void 0 ? void 0 : _classPrivateFieldLoo4.isMuted) !== null && _classPrivateFieldLoo3 !== void 0 ? _classPrivateFieldLoo3 : true; _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.setMicrophoneEnabled(isEnabled); }; this.toggleScreenShare = function () { var _classPrivateFieldLoo5; var isEnabled = (_classPrivateFieldLoo5 = _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.isScreenShareEnabled) !== null && _classPrivateFieldLoo5 !== void 0 ? _classPrivateFieldLoo5 : true; _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.setScreenShareEnabled(!isEnabled); }; this.initializeLocalTracks = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (_classPrivateFieldLooseBase(_this, _room)[_room].options.videoCaptureDefaults && _classPrivateFieldLooseBase(_this, _videoDeviceId)[_videoDeviceId]) { _classPrivateFieldLooseBase(_this, _room)[_room].options.videoCaptureDefaults.deviceId = _classPrivateFieldLooseBase(_this, _videoDeviceId)[_videoDeviceId]; } if (_classPrivateFieldLooseBase(_this, _room)[_room].options.audioCaptureDefaults && _classPrivateFieldLooseBase(_this, _audioDeviceId)[_audioDeviceId]) { _classPrivateFieldLooseBase(_this, _room)[_room].options.audioCaptureDefaults.deviceId = _classPrivateFieldLooseBase(_this, _audioDeviceId)[_audioDeviceId]; } _context.next = 4; return _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.setCameraEnabled(_classPrivateFieldLooseBase(_this, _isLocalVideoEnabled)[_isLocalVideoEnabled]); case 4: _context.next = 6; return _classPrivateFieldLooseBase(_this, _room)[_room].localParticipant.setMicrophoneEnabled(_classPrivateFieldLooseBase(_this, _isLocalAudioEnabled)[_isLocalAudioEnabled]); case 6: case "end": return _context.stop(); } }, _callee); })); _classPrivateFieldLooseBase(this, _room)[_room] = room; _classPrivateFieldLooseBase(this, _isLocalVideoEnabled)[_isLocalVideoEnabled] = isVideoEnabled; _classPrivateFieldLooseBase(this, _isLocalAudioEnabled)[_isLocalAudioEnabled] = isAudioEnabled; _classPrivateFieldLooseBase(this, _videoDeviceId)[_videoDeviceId] = videoDeviceId; _classPrivateFieldLooseBase(this, _audioDeviceId)[_audioDeviceId] = audioDeviceId; }); var LocalTrackController$1 = LocalTrackController; export { LocalTrackController$1 as default };