Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Settings.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* global JitsiMeetJS */
  2. import UIUtil from '../UI/util/UIUtil';
  3. let email = '';
  4. let displayName = '';
  5. let language = null;
  6. let cameraDeviceId = '';
  7. let micDeviceId = '';
  8. let welcomePageDisabled = false;
  9. let localFlipX = null;
  10. function supportsLocalStorage() {
  11. try {
  12. return 'localStorage' in window && window.localStorage !== null;
  13. } catch (e) {
  14. console.log("localstorage is not supported");
  15. return false;
  16. }
  17. }
  18. function generateUniqueId() {
  19. function _p8() {
  20. return (Math.random().toString(16) + "000000000").substr(2, 8);
  21. }
  22. return _p8() + _p8() + _p8() + _p8();
  23. }
  24. if (supportsLocalStorage()) {
  25. if (!window.localStorage.jitsiMeetId) {
  26. window.localStorage.jitsiMeetId = generateUniqueId();
  27. console.log("generated id", window.localStorage.jitsiMeetId);
  28. }
  29. email = UIUtil.unescapeHtml(window.localStorage.email || '');
  30. localFlipX = JSON.parse(window.localStorage.localFlipX || true);
  31. displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
  32. language = window.localStorage.language;
  33. cameraDeviceId = window.localStorage.cameraDeviceId || '';
  34. micDeviceId = window.localStorage.micDeviceId || '';
  35. welcomePageDisabled = JSON.parse(
  36. window.localStorage.welcomePageDisabled || false
  37. );
  38. // Currently audio output device change is supported only in Chrome and
  39. // default output always has 'default' device ID
  40. var audioOutputDeviceId = window.localStorage.audioOutputDeviceId
  41. || 'default';
  42. if (audioOutputDeviceId !==
  43. JitsiMeetJS.mediaDevices.getAudioOutputDevice()) {
  44. JitsiMeetJS.mediaDevices.setAudioOutputDevice(audioOutputDeviceId)
  45. .catch((ex) => {
  46. console.warn('Failed to set audio output device from local ' +
  47. 'storage. Default audio output device will be used' +
  48. 'instead.', ex);
  49. });
  50. }
  51. } else {
  52. console.log("local storage is not supported");
  53. }
  54. export default {
  55. /**
  56. * Sets the local user display name and saves it to local storage
  57. *
  58. * @param {string} newDisplayName unescaped display name for the local user
  59. */
  60. setDisplayName (newDisplayName) {
  61. displayName = newDisplayName;
  62. window.localStorage.displayname = UIUtil.escapeHtml(displayName);
  63. },
  64. /**
  65. * Returns the escaped display name currently used by the user
  66. * @returns {string} currently valid user display name.
  67. */
  68. getDisplayName: function () {
  69. return displayName;
  70. },
  71. /**
  72. * Sets new email for local user and saves it to the local storage.
  73. * @param {string} newEmail new email for the local user
  74. */
  75. setEmail: function (newEmail) {
  76. email = newEmail;
  77. window.localStorage.email = UIUtil.escapeHtml(newEmail);
  78. },
  79. /**
  80. * Returns email address of the local user.
  81. * @returns {string} email
  82. */
  83. getEmail: function () {
  84. return email;
  85. },
  86. getLanguage () {
  87. return language;
  88. },
  89. setLanguage: function (lang) {
  90. language = lang;
  91. window.localStorage.language = lang;
  92. },
  93. /**
  94. * Sets new flipX state of local video and saves it to the local storage.
  95. * @param {string} val flipX state of local video
  96. */
  97. setLocalFlipX: function (val) {
  98. localFlipX = val;
  99. window.localStorage.localFlipX = val;
  100. },
  101. /**
  102. * Returns flipX state of local video.
  103. * @returns {string} flipX
  104. */
  105. getLocalFlipX: function () {
  106. return localFlipX;
  107. },
  108. /**
  109. * Get device id of the camera which is currently in use.
  110. * Empty string stands for default device.
  111. * @returns {String}
  112. */
  113. getCameraDeviceId: function () {
  114. return cameraDeviceId;
  115. },
  116. /**
  117. * Set device id of the camera which is currently in use.
  118. * Empty string stands for default device.
  119. * @param {string} newId new camera device id
  120. */
  121. setCameraDeviceId: function (newId = '') {
  122. cameraDeviceId = newId;
  123. window.localStorage.cameraDeviceId = newId;
  124. },
  125. /**
  126. * Get device id of the microphone which is currently in use.
  127. * Empty string stands for default device.
  128. * @returns {String}
  129. */
  130. getMicDeviceId: function () {
  131. return micDeviceId;
  132. },
  133. /**
  134. * Set device id of the microphone which is currently in use.
  135. * Empty string stands for default device.
  136. * @param {string} newId new microphone device id
  137. */
  138. setMicDeviceId: function (newId = '') {
  139. micDeviceId = newId;
  140. window.localStorage.micDeviceId = newId;
  141. },
  142. /**
  143. * Get device id of the audio output device which is currently in use.
  144. * Empty string stands for default device.
  145. * @returns {String}
  146. */
  147. getAudioOutputDeviceId: function () {
  148. return JitsiMeetJS.mediaDevices.getAudioOutputDevice();
  149. },
  150. /**
  151. * Set device id of the audio output device which is currently in use.
  152. * Empty string stands for default device.
  153. * @param {string} newId='default' - new audio output device id
  154. * @returns {Promise}
  155. */
  156. setAudioOutputDeviceId: function (newId = 'default') {
  157. return JitsiMeetJS.mediaDevices.setAudioOutputDevice(newId)
  158. .then(() => window.localStorage.audioOutputDeviceId = newId);
  159. },
  160. /**
  161. * Check if welcome page is enabled or not.
  162. * @returns {boolean}
  163. */
  164. isWelcomePageEnabled () {
  165. return !welcomePageDisabled;
  166. },
  167. /**
  168. * Enable or disable welcome page.
  169. * @param {boolean} enabled if welcome page should be enabled or not
  170. */
  171. setWelcomePageEnabled (enabled) {
  172. welcomePageDisabled = !enabled;
  173. window.localStorage.welcomePageDisabled = welcomePageDisabled;
  174. }
  175. };