kaank-react-audio-recorder
Version:
72 lines • 1.95 kB
HTML
<head>
<meta charset="utf-8">
<title>Audio Recorder</title>
<style>
html, body {
margin: 0;
font-family: Monaco, Consolas;
}
.container {
max-width: 1024px;
margin: auto;
padding: 24px;
}
#app {
margin-bottom: 12px;
}
h1 {
margin-top: 0;
}
button {
border: 1px solid slategray;
border-right: none;
background-color: #efefff;
color: rebeccapurple;
padding: 4px;
font-size: 16px;
line-height: 1;
width: 150px;
}
button:first-of-type {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
button:last-of-type {
border-right: 1px solid slategray;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
button:hover {
background-color: wheat;
cursor: pointer;
transition: background-color 0.1s ease-out;
}
</style>
</head>
<body>
<div class="container">
<h1>react-audio-recorder example</h1>
<p><a href="https://github.com/kremonte/react-audio-recorder">View project on GitHub</a></p>
<div id="app"></div>
<div id="audio-duration"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.3.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.3.2/umd/react-dom.production.min.js"></script>
<script src="./dist/dist/AudioRecorder.min.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function() {
ReactDOM.render(
React.createElement(AudioRecorder.default, {
downloadable: true,
onChange: (evt) => {
document.getElementById('audio-duration').innerText =
'Recording: ' + (Math.round(evt.duration * 100) / 100) + ' sec';
}
}),
document.getElementById('app')
);
});
</script>
</body>
</html>