augnitorecorder
Advanced tools
Comparing version 1.0.23 to 1.0.24
@@ -29,4 +29,7 @@ export declare class AugnitoRecorder { | ||
); | ||
togglePauseResumeAudioStream(socketURL?: string): void; | ||
toggleStartStopAudioStream(socketURL?: string): void; | ||
togglePauseResumeAudioStream( | ||
audioDuration?: number, | ||
socketURL?: string | ||
): void; | ||
toggleStartStopAudioStream(audioDuration?: number, socketURL?: string): void; | ||
startAudio(): void; | ||
@@ -33,0 +36,0 @@ pauseAudio(): void; |
@@ -388,3 +388,3 @@ function _regeneratorRuntime() { | ||
var Executor = /*#__PURE__*/function () { | ||
function Executor(enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse) { | ||
function Executor(enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse, bufferSizeInterval) { | ||
_classCallCheck(this, Executor); | ||
@@ -400,2 +400,3 @@ this.worker; | ||
this.packetSeqId = 0; | ||
this.audioDuration = 0; | ||
this.shouldSendAudioDataSequence = shouldSendAudioDataSequence; | ||
@@ -407,2 +408,3 @@ this.heavyOp; | ||
this.socketTimeoutInterval = socketTimeoutInterval ? socketTimeoutInterval : SOCKET_TIMEOUT; | ||
this.bufferSizeInterval = bufferSizeInterval; | ||
} | ||
@@ -413,4 +415,5 @@ | ||
key: "Start", | ||
value: function Start(wsUrl) { | ||
value: function Start(duration, wsUrl) { | ||
var _this = this; | ||
this.audioDuration = duration; | ||
var workerScript = "\n (() => {\n (".concat(WorkerBlob.toString(), ")(").concat(JSON.stringify(DONE_MSG), ", ").concat(JSON.stringify(this.eosMessage), ", ").concat(JSON.stringify(CLOSE_MSG), ", ").concat(JSON.stringify(CONNECT_RETRY_TIMEOUT), ", ").concat(JSON.stringify(this.socketTimeoutInterval), ", ").concat(JSON.stringify(HEALTHCHECK_INTERVAL), ", ").concat(JSON.stringify(CONSUME_INTERVAL), ", ").concat(JSON.stringify(wsUrl), ", ").concat(JSON.stringify(this.enableLogs), ", ").concat(JSON.stringify(this.shouldSendAudioDataSequence), ", ").concat(JSON.stringify(this.heavyOp), ");\n })();\n"); | ||
@@ -446,2 +449,6 @@ this.worker = new Worker(URL.createObjectURL(new Blob([workerScript], { | ||
value: function createAudioPacketHeader(isLastPacket) { | ||
if (this.audioDuration > 0) { | ||
this.packetSeqId = Math.ceil(this.audioDuration / this.bufferSizeInterval) + 1; | ||
this.audioDuration = 0; | ||
} | ||
this.packetSeqId++; | ||
@@ -541,3 +548,2 @@ var headerSize = 16; | ||
if (sentPacketsQueue.length > 0) { | ||
console.log("resend packet queue is filled"); | ||
retrySentPacket = true; | ||
@@ -683,3 +689,2 @@ } | ||
for (var i = 0; i < sentPacketsQueue.length; i++) { | ||
console.log("resend packet with id: ", sentPacketsQueue[i].packetNumber); | ||
var retryPacket = sentPacketsQueue[i].packetData; | ||
@@ -724,4 +729,5 @@ var res = send(retryPacket); | ||
JobID = ""; | ||
isDone = true; | ||
shouldNotReconnect = true; | ||
ws.close(); | ||
isDone = true; | ||
} else if (event.data === doneMessage) { | ||
@@ -746,3 +752,3 @@ add(doneMessage); | ||
this.audioContext = new AudioContext(); | ||
this.executor = new Executor(enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse); | ||
this.executor = new Executor(enableLogs, eosMessage, socketTimeoutInterval, shouldSendAudioDataSequence, onFinalResult, onPartialResult, onError, onSessionEvent, onOtherResults, onSpeechResponse, bufferSizeInterval); | ||
this.executor.HeavyOp = heavyOp; | ||
@@ -764,3 +770,3 @@ this.source; | ||
value: function () { | ||
var _StartStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(wsUrl) { | ||
var _StartStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(duration, wsUrl) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
@@ -770,3 +776,3 @@ while (1) switch (_context.prev = _context.next) { | ||
if (wsUrl !== "") { | ||
this.executor.Start(wsUrl); | ||
this.executor.Start(duration, wsUrl); | ||
} | ||
@@ -807,3 +813,3 @@ this.log("New stream started..."); | ||
})); | ||
function StartStream(_x) { | ||
function StartStream(_x, _x2) { | ||
return _StartStream.apply(this, arguments); | ||
@@ -1077,3 +1083,3 @@ } | ||
})); | ||
function StopStream(_x2) { | ||
function StopStream(_x3) { | ||
return _StopStream.apply(this, arguments); | ||
@@ -1094,2 +1100,3 @@ } | ||
this.audioContext.close(); | ||
this.audioData = []; | ||
} | ||
@@ -1199,3 +1206,4 @@ }, { | ||
value: function togglePauseResumeAudioStream() { | ||
var socketUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; | ||
var audioDuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
var socketUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; | ||
if (!this.streamer) { | ||
@@ -1205,3 +1213,3 @@ if (socketUrl) { | ||
} | ||
this.startAudio(); | ||
this.startAudio(audioDuration); | ||
} else { | ||
@@ -1218,3 +1226,4 @@ if (this.streamer.IsPaused) { | ||
value: function toggleStartStopAudioStream() { | ||
var socketUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined; | ||
var audioDuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
var socketUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; | ||
if (!this.streamer) { | ||
@@ -1224,3 +1233,3 @@ if (socketUrl) { | ||
} | ||
this.startAudio(); | ||
this.startAudio(audioDuration); | ||
} else { | ||
@@ -1232,5 +1241,5 @@ this.stopAudio(); | ||
key: "startAudio", | ||
value: function startAudio() { | ||
value: function startAudio(duration) { | ||
this.initialiseStreamer(); | ||
this.streamer.StartStream(this.WebsocketURL); | ||
this.streamer.StartStream(duration, this.WebsocketURL); | ||
this.log("Stream Started..."); | ||
@@ -1237,0 +1246,0 @@ } |
{ | ||
"name": "augnitorecorder", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "Audio recorder and streamer compatible with any browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/augnitoRecorder.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129772
1364