Skip to content

Commit 51f59aa

Browse files
committed
Adding AudioVideo, AudioVideoCheck, Video, and VideoCheck components.
1 parent 7c61f2e commit 51f59aa

File tree

10 files changed

+713
-78
lines changed

10 files changed

+713
-78
lines changed

src/components/InputSelector/InputSelector.vue

Lines changed: 89 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</div>
2424

2525
<div v-else-if="inputType === 'audioCheck'">
26-
<AudioRecord
26+
<AudioCheck
2727
:constraints="valueConstraints"
2828
:selected_language="selected_language"
2929
:init="init" v-on:valueChanged="sendData"/>
@@ -82,6 +82,13 @@
8282
mode="audioRecordNoStop" />
8383
</div>
8484

85+
<div v-else-if="inputType === 'audioVideoCheck'">
86+
<AudioVideoCheck
87+
:constraints="valueConstraints"
88+
:selected_language="selected_language"
89+
:init="init" v-on:valueChanged="sendData"/>
90+
</div>
91+
8592
<!-- If type is audioVideoRecord -->
8693
<div v-else-if="inputType === 'audioVideoRecord'">
8794
<AudioVideoRecord
@@ -97,7 +104,7 @@
97104
:init="init" v-on:valueChanged="sendData"/>
98105
</div>
99106

100-
<!-- If type is AudioVideoImageRecord -->
107+
<!-- If type is audioVideoImageRecord -->
101108
<div v-else-if="inputType === 'audioVideoImageRecord'">
102109
<AudioVideoRecord
103110
:constraints="valueConstraints"
@@ -107,7 +114,7 @@
107114
mode="audioVideoImageRecord" />
108115
</div>
109116

110-
<!-- If type is videoRecordNumberTask -->
117+
<!-- If type is audioRecordNumberTask -->
111118
<div v-else-if="inputType === 'audioVideoRecordNumberTask'">
112119
<AudioVideoRecord
113120
:constraints="valueConstraints"
@@ -116,8 +123,8 @@
116123
mode="audioVideoRecordNumberTask" />
117124
</div>
118125

119-
<!-- If type is videoRecordAudioTask -->
120-
<div v-else-if="inputType === 'videoRecordAudioTask'">
126+
<!-- If type is audioRecordAudioTask -->
127+
<div v-else-if="inputType === 'audioVideoRecordAudioTask'">
121128
<AudioVideoRecord
122129
:constraints="valueConstraints"
123130
:selected_language="selected_language"
@@ -126,7 +133,7 @@
126133
mode="audioVideoRecordAudioTask" />
127134
</div>
128135

129-
<!-- If type is videoRecordNoStop -->
136+
<!-- If type is audioVideoRecordNoStop -->
130137
<div v-else-if="inputType === 'audioVideoRecordNoStop'">
131138
<AudioVideoRecord
132139
:constraints="valueConstraints"
@@ -135,6 +142,66 @@
135142
mode="audioVideoRecordNoStop" />
136143
</div>
137144

145+
<div v-else-if="inputType === 'videoCheck'">
146+
<VideoCheck
147+
:constraints="valueConstraints"
148+
:selected_language="selected_language"
149+
:init="init" v-on:valueChanged="sendData"/>
150+
</div>
151+
152+
<!-- If type is VideoRecord -->
153+
<div v-else-if="inputType === 'videoRecord'">
154+
<VideoRecord
155+
:constraints="valueConstraints"
156+
:selected_language="selected_language"
157+
:init="init" v-on:valueChanged="sendData"/>
158+
</div>
159+
160+
<div v-else-if="inputType === 'videoPassageRecord'">
161+
<VideoRecord
162+
:constraints="valueConstraints"
163+
:selected_language="selected_language"
164+
:init="init" v-on:valueChanged="sendData"/>
165+
</div>
166+
167+
<!-- If type is videoImageRecord -->
168+
<div v-else-if="inputType === 'videoImageRecord'">
169+
<VideoRecord
170+
:constraints="valueConstraints"
171+
:fieldData="fieldData"
172+
:selected_language="selected_language"
173+
:init="init" v-on:valueChanged="sendData"
174+
mode="videoImageRecord" />
175+
</div>
176+
177+
<!-- If type is videoRecordNumberTask -->
178+
<div v-else-if="inputType === 'videoRecordNumberTask'">
179+
<VideoRecord
180+
:constraints="valueConstraints"
181+
:selected_language="selected_language"
182+
:init="init" v-on:valueChanged="sendData"
183+
mode="videoRecordNumberTask" />
184+
</div>
185+
186+
<!-- If type is videoRecordAudioTask -->
187+
<div v-else-if="inputType === 'videoRecordAudioTask'">
188+
<videoRecord
189+
:constraints="valueConstraints"
190+
:selected_language="selected_language"
191+
:init="init" v-on:valueChanged="sendData"
192+
:fieldData="fieldData"
193+
mode="videoRecordAudioTask" />
194+
</div>
195+
196+
<!-- If type is videoRecordNoStop -->
197+
<div v-else-if="inputType === 'videoRecordNoStop'">
198+
<VideoRecord
199+
:constraints="valueConstraints"
200+
:selected_language="selected_language"
201+
:init="init" v-on:valueChanged="sendData"
202+
mode="videoRecordNoStop" />
203+
</div>
204+
138205
<!-- If type is text -->
139206
<div v-else-if="inputType === 'text'">
140207
<TextInput
@@ -147,10 +214,10 @@
147214
<!-- If type is textarea-->
148215
<div v-else-if="inputType === 'textarea'">
149216
<TextArea
150-
:constraints="valueConstraints"
151-
:inputType="inputType"
152-
:selected_language="selected_language"
153-
:init="init" v-on:valueChanged="sendData"></TextArea>
217+
:constraints="valueConstraints"
218+
:inputType="inputType"
219+
:selected_language="selected_language"
220+
:init="init" v-on:valueChanged="sendData"/>
154221
</div>
155222

156223
<!-- If type is pid -->
@@ -301,8 +368,8 @@
301368
<script>
302369
import Radio from '../Inputs/WebRadio/';
303370
import AudioRecord from '../Inputs/WebAudioRecord/';
304-
import AudioVideoRecord from '../Inputs/WebAudioVideoRecord';
305-
import VideoRecord from '../Inputs/WebAudioVideoRecord';
371+
import AudioVideoRecord from '../Inputs/WebAudioVideoRecord/';
372+
import VideoRecord from '../Inputs/WebVideoRecord/';
306373
import TextInput from '../Inputs/WebTextInput/';
307374
import TextArea from '../Inputs/TextArea/';
308375
import IntegerInput from '../Inputs/WebIntegerInput/';
@@ -314,14 +381,17 @@ import MultiTextInput from '../Inputs/MultiTextInput';
314381
import SliderInput from '../Inputs/SliderInput';
315382
import TimeRange from '../Inputs/TimeRange';
316383
import SelectInput from '../Inputs/SelectInput';
317-
// import AudioCheck from '../Inputs/AudioCheck';
384+
import AudioCheck from '../Inputs/AudioCheck/';
385+
import VideoCheck from '../Inputs/VideoCheck/';
386+
import AudioVideoCheck from '../Inputs/AudioVideoCheck/';
318387
import StaticReadOnly from '../Inputs/StaticReadOnly';
319388
import SaveData from '../Inputs/SaveData/SaveData';
320389
import StudySign from '../StudySign/StudySign';
321390
// import Static from '../Inputs/Static';
322391
import EmailInput from '../Inputs/EmailInput';
323392
import ParticipantId from '../Inputs/ParticipantId/ParticipantId';
324393
394+
325395
export default {
326396
name: 'InputSelector',
327397
props: {
@@ -361,7 +431,6 @@ export default {
361431
ipAddress: {
362432
type: String,
363433
},
364-
365434
},
366435
components: {
367436
ParticipantId,
@@ -370,6 +439,10 @@ export default {
370439
Radio,
371440
AudioRecord,
372441
AudioVideoRecord,
442+
VideoRecord,
443+
AudioCheck,
444+
VideoCheck,
445+
AudioVideoCheck,
373446
TextInput,
374447
TextArea,
375448
EmailInput,
@@ -387,7 +460,8 @@ export default {
387460
},
388461
data() {
389462
return {
390-
}
463+
464+
};
391465
},
392466
methods: {
393467
skip() {

src/components/Inputs/AudioCheck/AudioCheck.vue

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
<b-button v-if="!isRecording && !hasRecording" @click="record" variant="danger">
66
{{ $t('start-button') }}
77
</b-button>
8+
<!--Added by Veronika - trying to open a select menu if audio input type not indicated-->
9+
<div v-if="(!audioStreamDevice)" onload="getDevices">
10+
<label>Please select the type of microphone you wish to use.</label>
11+
<select @change="nameDevice">
12+
<option v-for="device in devices" :key="device" :value="device">{{ device }}</option>
13+
</select>
14+
</div>
815
<div v-if="isRecording" class="container-fluid">
916
<div class="pids-wrapper">
1017
<div class="pid"></div>
@@ -80,7 +87,11 @@ export default {
8087
isRecording: false,
8188
hasRecording: false,
8289
audioCtx: {},
83-
audioConstraints: { audio: true, video: false },
90+
audioConstraints: {
91+
audio: {
92+
deviceId:{exact:this.audioStreamDevice},
93+
},
94+
video: false },
8495
// chunks: [],
8596
mediaRecorder: {},
8697
supported: null,
@@ -89,10 +100,33 @@ export default {
89100
isPlaying: false,
90101
selectedImage: null,
91102
hasError: false,
103+
devices: null,
104+
tempDeviceName: null
92105
};
93106
},
94107
methods: {
108+
getDevices() {
109+
navigator.mediaDevices.enumerateDevices().then((devices) => {
110+
const audioInputDevices = devices.filter((device) => device.kind === 'audioinput');
111+
this.devices = audioInputDevices.map((device) => device.label || `Microphone ${device.deviceId}`);
112+
this.tempDeviceName = devices[0]
113+
}).catch((err) => {
114+
console.error("Error enumerating devices:", err);
115+
});
116+
},
117+
selectAudioDevice(deviceId){
118+
this.audioStreamDevice = deviceId;
119+
},
120+
nameDevice(e){
121+
this.tempDeviceName = e.target.value
122+
},
123+
setDevice(){
124+
this.$store.state.selectedAudioInput = this.tempDeviceName;
125+
},
95126
record() {
127+
if (!this.audioStreamDevice){
128+
this.setDevice();
129+
}
96130
this.isRecording = true;
97131
this.mediaRecorder.start(this.recordingTime);
98132
this.interval = setInterval(this.countdown, 1000);
@@ -193,14 +227,18 @@ export default {
193227
},
194228
},
195229
computed: {
230+
audioStreamDevice(){
231+
return this.$store.state.selectedAudioInput;
232+
},
196233
recordingTime() {
197234
return this.constraints['http://schema.org/maxValue'][0]['@value'];
198235
},
199236
},
200237
mounted() {
201238
this.recording = new Audio();
202239
this.recording.onended = this.endPlay;
203-
240+
this.getDevices();
241+
204242
// Older browsers might not implement mediaDevices at all, so we set an empty object first
205243
if (navigator.mediaDevices === undefined) {
206244
navigator.mediaDevices = {};

0 commit comments

Comments
 (0)