-
-
Notifications
You must be signed in to change notification settings - Fork 311
/
audio-only-lamejs.html
105 lines (94 loc) · 3.28 KB
/
audio-only-lamejs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Lamejs Audio-only Example - Record Plugin for Video.js</title>
<link href="//vjs.zencdn.net/7.10.2/video-js.min.css" rel="stylesheet">
<link href="//unpkg.com/videojs-wavesurfer/dist/css/videojs.wavesurfer.min.css" rel="stylesheet">
<link href="//unpkg.com/videojs-record/dist/css/videojs.record.min.css" rel="stylesheet">
<link href="assets/examples.css" rel="stylesheet">
<script src="//vjs.zencdn.net/7.10.2/video.min.js"></script>
<script src="//unpkg.com/webrtc-adapter/out/adapter.js"></script>
<script src="//unpkg.com/wavesurfer.js/dist/wavesurfer.min.js"></script>
<script src="//unpkg.com/wavesurfer.js/dist/plugin/wavesurfer.microphone.min.js"></script>
<script src="//unpkg.com/videojs-wavesurfer/dist/videojs.wavesurfer.min.js"></script>
<script src="//unpkg.com/videojs-record/dist/videojs.record.min.js"></script>
<script src="//unpkg.com/videojs-record/dist/plugins/videojs.record.lamejs.min.js"></script>
<style>
/* change player background color */
#myAudio {
background-color: #493657;
}
</style>
</head>
<body>
<audio id="myAudio" class="video-js vjs-default-skin"></audio>
<script>
var options = {
controls: true,
bigPlayButton: false,
width: 600,
height: 300,
plugins: {
wavesurfer: {
backend: 'WebAudio',
waveColor: '#fffa00',
progressColor: '#FAFCD2',
cursorColor: '#fffa00',
debug: true,
cursorWidth: 1,
hideScrollbar: true,
plugins: [
// enable microphone plugin
WaveSurfer.microphone.create({
bufferSize: 4096,
numberOfInputChannels: 1,
numberOfOutputChannels: 1,
constraints: {
video: false,
audio: true
}
})
]
},
record: {
audio: true,
video: false,
maxLength: 20,
debug: true,
displayMilliseconds: true,
audioEngine: 'lamejs',
audioWorkerURL: 'lib/lamejs/worker-example/worker-realtime.js',
audioSampleRate: 44100,
audioBitRate: 128
}
}
};
var player = videojs('myAudio', options, function() {
// print version information at startup
var msg = 'Using video.js ' + videojs.VERSION +
' with videojs-record ' + videojs.getPluginVersion('record') +
', videojs-wavesurfer ' + videojs.getPluginVersion('wavesurfer') +
' and wavesurfer.js ' + WaveSurfer.VERSION;
videojs.log(msg);
});
// error handling
player.on('deviceError', function() {
console.log('device error:', player.deviceErrorCode);
});
player.on('error', function(element, error) {
console.error(error);
});
// user clicked the record button and started recording
player.on('startRecord', function() {
console.log('started recording!');
});
// user completed recording and stream is available
player.on('finishRecord', function() {
// the blob object contains the recorded data that
// can be downloaded by the user, stored on server etc.
console.log('finished recording: ', player.recordedData);
});
</script>
</body>
</html>