zoom_video_sdk_recording.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { ZoomVideoSDKErrors } from './zoom_video_sdk_defines.js'
  2. import messages from './electron_zoomvideosdk_pb.js'
  3. export default (function () {
  4. var instance
  5. /**
  6. * Return an instance to manage cloud recordings during a video SDK session.
  7. * @module zoom_video_sdk_recording
  8. * @return {ZoomVideoSDKLocalRecording}
  9. */
  10. function init(opts) {
  11. const clientOpts = {...opts}
  12. // Private methods and variables
  13. if (!clientOpts.addon) {
  14. return null
  15. }
  16. const _addon = clientOpts.addon.GetRecordingHelper()
  17. return {
  18. // Public methods and variables
  19. /**
  20. * Checks whether the current user has permission to start cloud recording.
  21. * @method canStartRecording
  22. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  23. Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  24. */
  25. canStartRecording: function () {
  26. if (_addon) {
  27. return _addon.CanStartRecording()
  28. }
  29. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  30. },
  31. /**
  32. * Start cloud recording.
  33. * @method startCloudRecording
  34. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  35. Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  36. */
  37. startCloudRecording: function () {
  38. if (_addon) {
  39. return _addon.StartCloudRecording()
  40. }
  41. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  42. },
  43. /**
  44. * Stop cloud recording.
  45. * @method stopCloudRecording
  46. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  47. Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  48. */
  49. stopCloudRecording: function () {
  50. if (_addon) {
  51. return _addon.StopCloudRecording()
  52. }
  53. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  54. },
  55. /**
  56. * Pause cloud recording.
  57. * @method pauseCloudRecording
  58. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  59. Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  60. */
  61. pauseCloudRecording: function () {
  62. if (_addon) {
  63. return _addon.PauseCloudRecording()
  64. }
  65. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  66. },
  67. /**
  68. * Resume cloud recording.
  69. * @method resumeCloudRecording
  70. * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
  71. Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  72. */
  73. resumeCloudRecording: function () {
  74. if (_addon) {
  75. return _addon.ResumeCloudRecording()
  76. }
  77. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  78. },
  79. /**
  80. * Get the current status of cloud recording.
  81. * @method getCloudRecordingStatus
  82. * @return {Number|Object} If the function succeed, the return value is recordingStatus.
  83. Otherwise return value is err Object. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
  84. */
  85. getCloudRecordingStatus: function () {
  86. if (_addon) {
  87. let {err, recordingStatus} = _addon.GetCloudRecordingStatus()
  88. if (err == ZoomVideoSDKErrors.ZoomVideoSDKErrors_Success) {
  89. return recordingStatus
  90. } else {
  91. return {err}
  92. }
  93. }
  94. return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
  95. }
  96. }
  97. };
  98. return {
  99. getInstance: function (opts) {
  100. if (!instance) {
  101. instance = init(opts)
  102. }
  103. return instance
  104. }
  105. }
  106. })()