Skip to content

Instantly share code, notes, and snippets.

View triloknagvenkar's full-sized avatar

Trilok Nagvenkar triloknagvenkar

View GitHub Profile
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListMultipartUploadParts",
"s3:ListBucketMultipartUploads"
<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>
/*
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) => {
@triloknagvenkar
triloknagvenkar / continueMultiUpload.js
Created December 11, 2018 16:23
Uploads a part in a multipart upload.
/*
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,
@triloknagvenkar
triloknagvenkar / startMultiUpload.js
Created December 11, 2018 16:22
Initiates a multipart upload and returns an upload ID.
/*
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,
/*
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;
@triloknagvenkar
triloknagvenkar / startRecording.js
Created December 11, 2018 16:19
Begins recording media into one or more Blob objects
/*
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;
@triloknagvenkar
triloknagvenkar / audioStreamInitialize.js
Created December 11, 2018 16:17
This function is used to request the microphone permission and on receiving the data for the time it will create a multipart upload
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)