RecordRTC实现麦克风录音成文件效果代码
代码语言:html
所属分类:多媒体
代码描述:RecordRTC实现麦克风录音成文件效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<section class="experiment">
<h2 class="header">
Record Audio ( <a href="http://recordrtc.org/" title="API Documentation">RecordRTC.org</a> )
</h2>
<div class="inner">
<audio id="audio" autoplay="" controls=""></audio>
<button id="record-audio">Record</button>
<button id="pause-resume-audio" disabled="">Pause</button>
<button id="stop-recording-audio" disabled="">Stop</button>
<h2 id="audio-url-preview"></h2>
</div>
<script src='https://cdn.webrtc-experiment.com/RecordRTC.js'></script>
<script src='https://cdn.webrtc-experiment.com/getScreenId.js'></script>
<script>
(function() {
var params = {},
r = /([^&=]+)=?([^&]*)/g;
function d(s) {
return decodeURIComponent(s.replace(/\+/g, ' '));
}
var match, search = window.location.search;
while (match = r.exec(search.substring(1)))
params[d(match[1])] = d(match[2]);
window.params = params;
})();
function getByID(id) {
return document.getElementById(id);
}
var recordAudio = getByID('record-audio'),
recordGIF = getByID('record-gif'),
stopRecordingAudio = getByID('stop-recording-audio'),
pauseResumeAudio = getByID('pause-resume-audio'),
pauseResumeGif = getByID('pause-resume-gif'),
stopRecordingGIF = getByID('stop-recording-gif');
var canvasWidth_input = getByID('canvas-width-input'),
canvasHeight_input = getByID('canvas-height-input');
if(params.canvas_width) {
canvasWidth_input.value = params.canvas_width;
}
if(params.canvas_height) {
canvasHeight_input.value = params.canvas_height;
}
var audio = getByID('audio');
var audioConstraints = {
audio: true,
video: false
};
var audioStream;
var recorder;
recordAudio.onclick = .........完整代码请登录后点击上方下载按钮下载查看
网友评论0