@@ -25,12 +25,11 @@ import { IForm } from "../formComp/formDataConstants";
25
25
import { SimpleNameComp } from "../simpleNameComp" ;
26
26
import { ButtonStyleControl } from "./videobuttonCompConstants" ;
27
27
import { RefControl } from "comps/controls/refControl" ;
28
- import { useEffect , useRef } from "react" ;
28
+ import { useEffect , useRef , useState } from "react" ;
29
29
30
30
import { AutoHeightControl } from "comps/controls/autoHeightControl" ;
31
31
import {
32
32
client ,
33
- meetingControllerChildren ,
34
33
} from "./videoMeetingControllerComp" ;
35
34
36
35
import { IAgoraRTCRemoteUser } from "agora-rtc-sdk-ng" ;
@@ -61,8 +60,7 @@ const Container = styled.div<{ $style: any }>`
61
60
display: flex;
62
61
align-items: center;
63
62
justify-content: center;
64
- ` ; // ${(props) => props.$style && getStyle(props.$style)} - they should be applyed to VideoContainer only
65
-
63
+ ` ;
66
64
const VideoContainer = styled . video < { $style : any } > `
67
65
height: 100%;
68
66
width: 100%;
@@ -154,13 +152,9 @@ const typeOptions = [
154
152
} ,
155
153
] as const ;
156
154
157
- export const videoShared = ( ) => {
158
- console . log ( "data" ) ;
159
- } ;
160
155
export const meetingStreamChildren = {
161
156
autoHeight : withDefault ( AutoHeightControl , "fixed" ) ,
162
157
type : dropdownControl ( typeOptions , "" ) ,
163
- // onEvent: ButtonEventHandlerControl,
164
158
onEvent : MeetingEventHandlerControl ,
165
159
disabled : BoolCodeControl ,
166
160
loading : BoolCodeControl ,
@@ -169,27 +163,28 @@ export const meetingStreamChildren = {
169
163
suffixIcon : IconControl ,
170
164
style : ButtonStyleControl ,
171
165
viewRef : RefControl < HTMLElement > ,
172
- // viewRef: RefControl<BaseStreamRef>,
173
- userId : stringExposingStateControl ( "user id" , trans ( "meeting.userId" ) ) ,
166
+ userId : stringExposingStateControl ( "" ) ,
174
167
} ;
175
168
176
169
let VideoCompBuilder = ( function ( props ) {
177
- return (
178
- new UICompBuilder ( meetingStreamChildren , ( props ) => {
179
- const videoRef = useRef < HTMLVideoElement > ( null ) ;
180
- const conRef = useRef < HTMLDivElement > ( null ) ;
170
+ return new UICompBuilder ( meetingStreamChildren , ( props ) => {
171
+ const videoRef = useRef < HTMLVideoElement > ( null ) ;
172
+ const conRef = useRef < HTMLDivElement > ( null ) ;
173
+ const [ userId , setUserId ] = useState ( ) ;
181
174
182
- useEffect ( ( ) => {
183
- onResize ( ) ;
184
- } , [ ] ) ;
175
+ useEffect ( ( ) => {
176
+ onResize ( ) ;
177
+ } , [ ] ) ;
185
178
186
- const onResize = async ( ) => {
187
- const container = conRef . current ;
188
- let videoCo = videoRef . current ;
189
- videoCo ! . style . height = container ?. clientHeight + "px" ;
190
- videoCo ! . style . width = container ?. clientWidth + "px" ;
191
- } ;
192
- useEffect ( ( ) => {
179
+ const onResize = async ( ) => {
180
+ const container = conRef . current ;
181
+ let videoCo = videoRef . current ;
182
+ videoCo ! . style . height = container ?. clientHeight + "px" ;
183
+ videoCo ! . style . width = container ?. clientWidth + "px" ;
184
+ } ;
185
+ useEffect ( ( ) => {
186
+ if ( props . userId . value !== "" ) {
187
+ let userData = JSON . parse ( props . userId ?. value ) ;
193
188
client . on (
194
189
"user-published" ,
195
190
async ( user : IAgoraRTCRemoteUser , mediaType : "video" | "audio" ) => {
@@ -198,10 +193,10 @@ let VideoCompBuilder = (function (props) {
198
193
let userId = user . uid + "" ;
199
194
if (
200
195
user . hasVideo &&
201
- user . uid + "" != props . userId . value &&
202
- props . userId . value != ""
196
+ user . uid + "" != userData . user &&
197
+ userData . user != ""
203
198
) {
204
- props . onEvent ( "videoActiveInactive " ) ;
199
+ props . onEvent ( "videoOn " ) ;
205
200
}
206
201
const element = document . getElementById ( userId ) ;
207
202
if ( element ) {
@@ -212,10 +207,12 @@ let VideoCompBuilder = (function (props) {
212
207
const remoteTrack = await client . subscribe ( user , mediaType ) ;
213
208
if (
214
209
user . hasAudio &&
215
- user . uid + "" != props . userId . value &&
216
- props . userId . value != ""
210
+ user . uid + "" != userData . user &&
211
+ userData . user != ""
217
212
) {
218
- props . onEvent ( "audioMuteUnmute" ) ;
213
+ userData . audiostatus = user . hasVideo ;
214
+
215
+ props . onEvent ( "audioUnmuted" ) ;
219
216
}
220
217
remoteTrack . play ( ) ;
221
218
}
@@ -227,67 +224,67 @@ let VideoCompBuilder = (function (props) {
227
224
if ( mediaType === "audio" ) {
228
225
if (
229
226
! user . hasAudio &&
230
- user . uid + "" != props . userId . value &&
231
- props . userId . value != ""
227
+ user . uid + "" != userData . user &&
228
+ userData . user != ""
232
229
) {
233
- props . onEvent ( "audioMuteUnmute" ) ;
230
+ userData . audiostatus = user . hasVideo ;
231
+ props . onEvent ( "audioMuted" ) ;
234
232
}
235
233
}
236
234
if ( mediaType === "video" ) {
237
235
if (
238
236
! user . hasVideo &&
239
- user . uid + "" != props . userId . value &&
240
- props . userId . value != ""
237
+ user . uid + "" != userData . user &&
238
+ userData . user != ""
241
239
) {
242
- props . onEvent ( "videoActiveInactive " ) ;
240
+ props . onEvent ( "videoOff " ) ;
243
241
}
244
242
}
245
243
}
246
244
) ;
247
- } , [ props . userId . value ] ) ;
245
+ setUserId ( userData . user ) ;
246
+ }
247
+ } , [ props . userId . value ] ) ;
248
248
249
- return (
250
- < EditorContext . Consumer >
251
- { ( editorState ) => (
252
- < ReactResizeDetector onResize = { onResize } >
253
- < Container ref = { conRef } $style = { props . style } >
254
- < VideoContainer
255
- onClick = { ( ) => props . onEvent ( "videoClicked" ) }
256
- ref = { videoRef }
257
- $style = { props . style }
258
- id = { props . userId . value }
259
- > </ VideoContainer >
260
- </ Container >
261
- </ ReactResizeDetector >
262
- ) }
263
- </ EditorContext . Consumer >
264
- ) ;
265
- } )
266
- . setPropertyViewFn ( ( children ) => (
267
- < >
268
- < Section name = { sectionNames . basic } >
269
- { children . userId . propertyView ( { label : trans ( "meeting.videoId" ) } ) }
270
- { children . autoHeight . getPropertyView ( ) }
271
- </ Section >
272
- < Section name = { sectionNames . interaction } >
273
- { children . onEvent . getPropertyView ( ) }
274
- </ Section >
275
- < Section name = { sectionNames . layout } >
276
- { hiddenPropertyView ( children ) }
277
- </ Section >
278
- < Section name = { sectionNames . style } >
279
- { children . style . getPropertyView ( ) }
280
- </ Section >
281
- </ >
282
- ) )
283
- // .setExposeMethodConfigs(refMethods<BaseStreamRef>([shareMethod]))
284
- . build ( )
285
- ) ;
249
+
250
+
251
+ return (
252
+ < EditorContext . Consumer >
253
+ { ( editorState ) => (
254
+ < ReactResizeDetector onResize = { onResize } >
255
+ < Container ref = { conRef } $style = { props . style } >
256
+ < VideoContainer
257
+ onClick = { ( ) => props . onEvent ( "videoClicked" ) }
258
+ ref = { videoRef }
259
+ $style = { props . style }
260
+ id = { userId }
261
+ > </ VideoContainer >
262
+ </ Container >
263
+ </ ReactResizeDetector >
264
+ ) }
265
+ </ EditorContext . Consumer >
266
+ ) ;
267
+ } )
268
+ . setPropertyViewFn ( ( children ) => (
269
+ < >
270
+ < Section name = { sectionNames . basic } >
271
+ { children . userId . propertyView ( { label : trans ( "meeting.videoId" ) } ) }
272
+ { children . autoHeight . getPropertyView ( ) }
273
+ </ Section >
274
+ < Section name = { sectionNames . interaction } >
275
+ { children . onEvent . getPropertyView ( ) }
276
+ </ Section >
277
+ < Section name = { sectionNames . layout } >
278
+ { hiddenPropertyView ( children ) }
279
+ </ Section >
280
+ < Section name = { sectionNames . style } >
281
+ { children . style . getPropertyView ( ) }
282
+ </ Section >
283
+ </ >
284
+ ) )
285
+ . build ( ) ;
286
286
} ) ( ) ;
287
287
288
- // interface BaseStreamRef {
289
- // shared: () => void;
290
- // }
291
288
VideoCompBuilder = class extends VideoCompBuilder {
292
289
override autoHeight ( ) : boolean {
293
290
return this . children . autoHeight . getView ( ) ;
0 commit comments