|
1 | 1 | <script setup> |
2 | | -import { Head, Link, useForm, usePage } from '@inertiajs/vue3'; |
| 2 | +import { Head, Link, useForm } from '@inertiajs/vue3'; |
3 | 3 | import PrimaryButton from '@/Components/PrimaryButton.vue'; |
4 | | -import InputLabel from '@/components/InputLabel.vue'; |
5 | | -import TextInput from '@/components/TextInput.vue'; |
6 | | -import {onMounted} from 'vue' |
| 4 | +import InputLabel from '@/Components/InputLabel.vue'; |
| 5 | +import TextInput from '@/Components/TextInput.vue'; |
| 6 | +import {onMounted, ref} from 'vue' |
7 | 7 | const props = defineProps({ |
8 | 8 | callerId: { |
9 | 9 | type: String, |
10 | 10 |
|
| 11 | + }, |
| 12 | + canLogin: { |
| 13 | + type: Boolean, |
| 14 | +
|
| 15 | + }, |
| 16 | + canRegister: { |
| 17 | + type: Boolean, |
| 18 | +
|
11 | 19 | } |
12 | 20 | }) |
13 | | -
|
| 21 | +const hasStream = ref(false); |
14 | 22 | const pc = new RTCPeerConnection(); |
15 | | -let stream = null; |
16 | | -const grantPermissions = async (constraints = {audio: true}) => { |
| 23 | +const stream = ref(null); |
| 24 | +const grantPermissions = async (evt, constraints = {audio: true, video: false}) => { |
17 | 25 | try { |
18 | | - stream = await navigator.mediaDevices.getUserMedia(constraints); |
19 | | - for (const track of stream.getTracks()) { |
20 | | - pc.addTrack(track, stream); |
| 26 | + console.log(constraints) |
| 27 | + stream.value= await navigator.mediaDevices.getUserMedia(constraints); |
| 28 | + for (const track of stream.value.getTracks()) { |
| 29 | + pc.addTrack(track, stream.value); |
21 | 30 | } |
| 31 | + hasStream.value = true |
22 | 32 | /* use the stream */ |
23 | 33 | } catch (err) { |
24 | 34 | /* handle the error */ |
| 35 | + console.log(err) |
25 | 36 | } |
26 | 37 | } |
27 | 38 | const form = useForm({ |
@@ -194,6 +205,7 @@ onMounted(() => { |
194 | 205 | <PrimaryButton |
195 | 206 | class="ms-4" |
196 | 207 | @click="grantPermissions" |
| 208 | + :v-show="hasStream" |
197 | 209 | > |
198 | 210 | Grant Permissions |
199 | 211 | </PrimaryButton> |
|
0 commit comments