|
12 | 12 | <video v-show="!hasRecording" ref="live" id="live_recording" playsinline autoplay muted></video> |
13 | 13 | <video v-show="hasRecording && isPlaying" ref="recorded" id="recorded-footage" playsinline autoplay></video> |
14 | 14 | </div> |
| 15 | + <div v-if="audio && visualizer" class="container-fluid"> |
| 16 | + <div class="pids-wrapper"> |
| 17 | + <div v-for="i in 10" :key="i" class="pid"></div> |
| 18 | + </div> |
| 19 | + </div> |
15 | 20 | <div v-if="audio && !audioStreamDevice" class="mt-2"> |
16 | 21 | <label>{{ $t('select-microphone') }}</label> |
17 | 22 | <select v-model="tempDeviceName" class="form-control"> |
|
55 | 60 | import _ from 'lodash'; |
56 | 61 | const MediaStreamRecorder = require('msr'); |
57 | 62 |
|
| 63 | +function handleInit(newInit) { |
| 64 | + if (newInit === 'skip' || newInit === 'dontKnow') { |
| 65 | + this.hasRecording = false; |
| 66 | + } else if (newInit) { |
| 67 | + if (_.isString(newInit) && newInit.startsWith('blob')) { |
| 68 | + if (this.video) { |
| 69 | + this.recording.src = newInit; |
| 70 | + } else { |
| 71 | + this.recording = new Audio(newInit); |
| 72 | + this.recording.onended = this.endPlay; |
| 73 | + } |
| 74 | + this.hasRecording = true; |
| 75 | + } else if (newInit instanceof Blob) { |
| 76 | + const blobURL = URL.createObjectURL(newInit); |
| 77 | + if (this.video) { |
| 78 | + this.recording.src = blobURL; |
| 79 | + } else { |
| 80 | + this.recording = new Audio(blobURL); |
| 81 | + this.recording.onended = this.endPlay; |
| 82 | + } |
| 83 | + this.recording.blob = newInit; |
| 84 | + this.hasRecording = true; |
| 85 | + } |
| 86 | + } |
| 87 | +} |
| 88 | +
|
58 | 89 | export default { |
59 | 90 | name: 'MediaRecord', |
60 | 91 | props: { |
@@ -134,6 +165,21 @@ export default { |
134 | 165 | return ''; |
135 | 166 | }, |
136 | 167 | }, |
| 168 | + watch: { |
| 169 | + init: handleInit, |
| 170 | + }, |
| 171 | + mounted() { |
| 172 | + if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { |
| 173 | + this.supported = true; |
| 174 | + if (this.audio) { |
| 175 | + this.getDevices(); |
| 176 | + } |
| 177 | + this.initializeMedia(); |
| 178 | + } else { |
| 179 | + this.supported = false; |
| 180 | + } |
| 181 | + handleInit.call(this, this.init); |
| 182 | + }, |
137 | 183 | methods: { |
138 | 184 | getDevices() { |
139 | 185 | navigator.mediaDevices.enumerateDevices().then((devices) => { |
@@ -264,43 +310,5 @@ export default { |
264 | 310 | }; |
265 | 311 | }, |
266 | 312 | }, |
267 | | - watch: { |
268 | | - init(newInit) { |
269 | | - if (newInit === 'skip' || newInit === 'dontKnow') { |
270 | | - this.hasRecording = false; |
271 | | - } else if (newInit) { |
272 | | - if (_.isString(newInit) && newInit.startsWith('blob')) { |
273 | | - if (this.video) { |
274 | | - this.recording.src = newInit; |
275 | | - } else { |
276 | | - this.recording = new Audio(newInit); |
277 | | - this.recording.onended = this.endPlay; |
278 | | - } |
279 | | - this.hasRecording = true; |
280 | | - } else if (newInit instanceof Blob) { |
281 | | - const blobURL = URL.createObjectURL(newInit); |
282 | | - if (this.video) { |
283 | | - this.recording.src = blobURL; |
284 | | - } else { |
285 | | - this.recording = new Audio(blobURL); |
286 | | - this.recording.onended = this.endPlay; |
287 | | - } |
288 | | - this.recording.blob = newInit; |
289 | | - this.hasRecording = true; |
290 | | - } |
291 | | - } |
292 | | - }, |
293 | | - }, |
294 | | - mounted() { |
295 | | - if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { |
296 | | - this.supported = true; |
297 | | - if (this.audio) { |
298 | | - this.getDevices(); |
299 | | - } |
300 | | - this.initializeMedia(); |
301 | | - } else { |
302 | | - this.supported = false; |
303 | | - } |
304 | | - }, |
305 | 313 | }; |
306 | 314 | </script> |
0 commit comments