1
1
<template >
2
2
<v-row >
3
- <v-col class =" mt-8" cols =" 12" >
4
- <video ref =" remoteVideo" class =" video" autoplay playsinline />
5
- <video
6
- ref =" localVideo"
7
- class =" video ml-8"
8
- style =" height : 10vw "
9
- muted
10
- autoplay
11
- playsinline
12
- />
3
+ <v-col class =" mt-8" cols =" 8" >
4
+ <video ref =" remoteMedia" class =" video" muted autoplay playsinline />
5
+ </v-col >
6
+ <v-col class =" mt-8" cols =" 4" >
7
+ <video ref =" localMedia" class =" video" muted autoplay playsinline />
13
8
</v-col >
14
9
<v-col cols =" 12" >
15
10
<v-row justify =" center" >
16
11
<v-btn
17
- v-if =" localStream"
18
- disabled
19
- class =" mt-4 mx-2"
20
- :dark =" isSharingScreen"
21
- :class =" { red: isSharingScreen, ' ': !isSharingScreen }"
22
- fab
23
- @click =" toggleScreen()"
24
- >
25
- <v-icon v-if =" !isSharingScreen" >
26
- mdi-monitor-screenshot
27
- </v-icon >
28
- <v-icon v-else >
29
- mdi-monitor-off
30
- </v-icon >
31
- </v-btn >
32
- <v-btn
33
- v-if =" localStream"
12
+ v-if =" localCameraStream"
34
13
class =" mt-4 mx-2"
35
14
:dark =" isMicrophoneMuted"
36
15
:class =" { red: isMicrophoneMuted, white: !isMicrophoneMuted }"
44
23
mdi-microphone-off
45
24
</v-icon >
46
25
</v-btn >
47
- <!-- <v-btn
48
- v-if="localStream"
49
- class="mt-4 mx-2"
50
- dark
51
- color="red"
52
- fab
53
- @click="hangUp()"
26
+ <v-btn class =" mt-4 mx-2 white" fab @click =" toggleCameraScreen" >
27
+ <v-icon >
28
+ mdi-monitor-screenshot
29
+ </v-icon ></v-btn
54
30
>
55
- <v-icon>mdi-phone-hangup</v-icon>
56
- </v-btn> -->
57
31
</v-row >
58
32
</v-col >
59
- <VideoCall ref =" VideoCall" />
60
33
</v-row >
61
34
</template >
62
35
63
36
<script >
64
- import VideoCall from ' ./VideoCall.vue'
65
37
export default {
66
- components: {
67
- VideoCall,
68
- },
69
38
props: {
70
39
isAdmin: {
71
40
type: Boolean ,
@@ -80,48 +49,73 @@ export default {
80
49
hide: true ,
81
50
isMicrophoneMuted: false ,
82
51
isSharingScreen: false ,
52
+ usingCamera: true ,
83
53
}
84
54
},
85
-
86
55
computed: {
87
- localStream () {
88
- return this .$store .getters .localStream
56
+ localCameraStream () {
57
+ return this .$store .getters .localCameraStream
89
58
},
90
- remoteStream () {
91
- return this .$store .getters .remoteStream
59
+ remoteCameraStream () {
60
+ return this .$store .getters .remoteCameraStream
92
61
},
93
62
roomTestId () {
94
63
return this .$store .getters .test .id
95
64
},
65
+ peerConnection () {
66
+ return this .$store .getters .peerConnection
67
+ },
96
68
},
97
69
mounted () {
98
70
this .setupStreams ()
99
71
},
100
- methods: {
101
- async toggleScreen () {
102
- if (! this .isSharingScreen ) {
103
- await this .$refs .VideoCall .switchMediaStream ()
104
- this .isSharingScreen = true
105
- this .setupStreams ()
106
- } else if (this .isSharingScreen ) {
107
- this .isSharingScreen = false
108
- this .setupStreams ()
109
- this .$refs .VideoCall .joinRoomById (this .roomTestId )
110
- }
72
+ watch: {
73
+ localCameraStream (newVal ) {
74
+ this .setupStreams ()
75
+ },
76
+ remoteCameraStream (newVal ) {
77
+ this .setupStreams ()
111
78
},
79
+ },
80
+ methods: {
112
81
setupStreams () {
113
- this .$refs .localVideo .srcObject = this .localStream
114
- this .$refs .remoteVideo .srcObject = this .remoteStream
82
+ this .$refs .localMedia .srcObject = this .localCameraStream
83
+ this .$refs .remoteMedia .srcObject = this .remoteCameraStream
115
84
},
116
85
toggleMicrophone () {
117
- if (this .localStream && this .localStream .getAudioTracks ().length > 0 ) {
118
- const audioTrack = this .localStream
86
+ if (
87
+ this .localCameraStream &&
88
+ this .localCameraStream .getAudioTracks ().length > 0
89
+ ) {
90
+ const audioTrack = this .localCameraStream
119
91
.getTracks ()
120
92
.find ((track ) => track .kind == ' audio' )
121
93
audioTrack .enabled = ! audioTrack .enabled
122
94
this .isMicrophoneMuted = ! audioTrack .enabled
123
95
}
124
96
},
97
+ async toggleCameraScreen () {
98
+ try {
99
+ let stream
100
+
101
+ if (this .usingCamera ) {
102
+ stream = await navigator .mediaDevices .getDisplayMedia ({
103
+ video: true ,
104
+ })
105
+ } else {
106
+ stream = await navigator .mediaDevices .getUserMedia ({
107
+ video: true ,
108
+ })
109
+ }
110
+
111
+ if (stream) {
112
+ await this .$store .dispatch (' changeTrack' , stream)
113
+ this .usingCamera = ! this .usingCamera
114
+ }
115
+ } catch (e) {
116
+ this .$toast .error (' Error in toggling camera/screen: ' + e .message )
117
+ }
118
+ },
125
119
hangUp () {
126
120
this .$router .push (' /testslist' )
127
121
},
@@ -132,6 +126,7 @@ export default {
132
126
<style scoped>
133
127
.video {
134
128
border-radius : 30px ;
135
- height : 36vw ;
129
+ width : 100% ;
130
+ object-fit : contain ;
136
131
}
137
132
</style >
0 commit comments