Skip to content

Commit 5e412dd

Browse files
committed
audio
1 parent a948d21 commit 5e412dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

resources/js/Pages/Welcome.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const grantPermissions = async (evt, constraints = {audio: true, video: false})
2626
console.log(constraints)
2727
stream.value= await navigator.mediaDevices.getUserMedia(constraints);
2828
for (const track of stream.value.getTracks()) {
29-
pc.addTrack(track, stream.value);
29+
pc.addTrack(track);
3030
}
3131
hasStream.value = true
3232
/* use the stream */
@@ -85,6 +85,10 @@ pc.ondatachannel = (e) => {
8585
}
8686
pc.ontrack = (e) => {
8787
console.log('New track', e)
88+
let inboundStream = new MediaStream([e.track]);
89+
const audio = new Audio()
90+
audio.srcObject = inboundStream;
91+
audio.play()
8892
}
8993
onMounted(() => {
9094
@@ -205,7 +209,7 @@ onMounted(() => {
205209
<PrimaryButton
206210
class="ms-4"
207211
@click="grantPermissions"
208-
:v-show="hasStream"
212+
v-if="!hasStream"
209213
>
210214
Grant Permissions
211215
</PrimaryButton>

0 commit comments

Comments
 (0)