Skip to content

Commit 4c02651

Browse files
committed
add audio tracks
1 parent 5743117 commit 4c02651

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

resources/js/Pages/Welcome.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ const props = defineProps({
1111
}
1212
})
1313
14-
14+
const pc = new RTCPeerConnection();
15+
let stream = null;
16+
const grantPermissions = async (constraints = {audio: true}) => {
17+
try {
18+
stream = await navigator.mediaDevices.getUserMedia(constraints);
19+
for (const track of stream.getTracks()) {
20+
pc.addTrack(track, stream);
21+
}
22+
/* use the stream */
23+
} catch (err) {
24+
/* handle the error */
25+
}
26+
}
1527
const form = useForm({
1628
caller_id: '',
1729
sdp: {}
@@ -57,7 +69,6 @@ const answer = async (caller_id) => {
5769
},
5870
});
5971
};
60-
const pc = new RTCPeerConnection();
6172
pc.ondatachannel = (e) => {
6273
console.log('New data channel', e)
6374
}
@@ -179,6 +190,13 @@ onMounted(() => {
179190
Call
180191
</PrimaryButton>
181192
</form>
193+
194+
<PrimaryButton
195+
class="ms-4"
196+
@click="grantPermissions"
197+
>
198+
Grant Permissions
199+
</PrimaryButton>
182200
</p>
183201

184202

0 commit comments

Comments
 (0)