Skip to content

Instantly share code, notes, and snippets.

@saiganov
Last active July 5, 2020 07:25
Show Gist options
  • Save saiganov/c04207dc496d5bb5a0344983497a7c18 to your computer and use it in GitHub Desktop.
Save saiganov/c04207dc496d5bb5a0344983497a7c18 to your computer and use it in GitHub Desktop.
records
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber gist uses dumber bundler, the default bundle file
is /dist/entry-bundle.js.
The starting module is pointed to aurelia-bootstrapper
(data-main attribute on script) for Aurelia,
The aurelia bootstrapper then loads up user module "main"
(aurelia-app attribute on <body>) which is your src/main.ts.
-->
<body aurelia-app="main">
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script>
</body>
</html>
{
"dependencies": {
"aurelia-bootstrapper": "^2.3.3",
"recorderjs": "^1.0.1"
}
}
<template>
<!-- Try to create a css/scss/sass/less file then require it here -->
<h1>${message}</h1>
<button click.trigger="startRecording()">Record</button>
</template>
import * as Recorder from 'recorderjs';
export class App {
public message: string = 'Hello Aurelia!';
gumStream: any;
rec: any;
input: any;
AudioContext = window.AudioContext;
audioContext: AudioContext;
startRecording() {
console.log("recordButton clicked");
var constraints = { audio: true, video:false }
const self = this;
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
console.log("getUserMedia() success, stream created, initializing Recorder.js ...");
self.audioContext = new AudioContext();
self.gumStream = stream;
self.input = self.audioContext.createMediaStreamSource(stream);
self.rec = new Recorder(self.input,{numChannels:1})
self.rec.record()
console.log("Recording started");
}).catch(function(err) {
console.log('err', err)
});
}
}
import {Aurelia} from 'aurelia-framework';
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging('info');
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment