This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:GetObject", | |
"s3:ListMultipartUploadParts", | |
"s3:ListBucketMultipartUploads" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button type="button" class="btn kc record" id="record_q1" disabled="disabled" onclick="AudioStream.startRecording(this.id)">Record</button> | |
<button type="button" class="btn kc stop" id="stop_q1" disabled="disabled" onclick="AudioStream.stopRecording(this.id)">Stop</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Completes a multipart upload by assembling previously uploaded parts. | |
*/ | |
completeMultiUpload() { | |
var self = this; | |
var outputTag = []; | |
/* | |
here we are constructing the Etag data in the required format. | |
*/ | |
self.etag.forEach((data, index) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Uploads a part in a multipart upload. | |
The following code uploads part of a multipart upload. | |
it specifies a file name for the part data. The Upload ID is same that is returned by the initiate multipart upload. | |
*/ | |
continueMultiUpload(audioBlob, PartNumber, uploadId, key, bucketName) { | |
var self = this; | |
var params = { | |
Body: audioBlob, | |
Bucket: bucketName, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Initiates a multipart upload and returns an upload ID. | |
Upload id is used to upload the other parts of the stream | |
*/ | |
startMultiUpload(blob, filename) { | |
var self = this; | |
var audioBlob = blob; | |
var params = { | |
Bucket: self.bucketName, | |
Key: filename, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
When the stop() method is invoked, the UA queues a task that runs the following steps: | |
1 - If MediaRecorder.state is "inactive", raise a DOM InvalidState error and terminate these steps. | |
If the MediaRecorder.state is not "inactive", continue on to the next step. | |
2 - Set the MediaRecorder.state to "inactive" and stop capturing media. | |
3 - Raise a dataavailable event containing the Blob of data that has been gathered. | |
4 - Raise a stop event. | |
*/ | |
stopRecording(id) { | |
var self = this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The MediaRecorder method start(), which is part of the MediaStream Recording API, | |
begins recording media into one or more Blob objects. | |
You can record the entire duration of the media into a single Blob (or until you call requestData()), | |
or you can specify the number of milliseconds to record at a time. | |
Then, each time that amount of media has been recorded, an event will be delivered to let you act upon the recorded media, | |
while a new Blob is created to record the next slice of the media | |
*/ | |
startRecording(id) { | |
var self = this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
audioStreamInitialize() { | |
/* | |
Feature detecting is a simple check for the existence of "navigator.mediaDevices.getUserMedia" | |
To use the microphone. we need to request permission. | |
The parameter to getUserMedia() is an object specifying the details and requirements for each type of media you want to access. | |
To use microphone it shud be {audio: true} | |
*/ | |
navigator.mediaDevices.getUserMedia(self.audioConstraints) |