@@ -25,12 +25,11 @@ import { IForm } from "../formComp/formDataConstants";
2525import { SimpleNameComp } from "../simpleNameComp" ;
2626import { ButtonStyleControl } from "./videobuttonCompConstants" ;
2727import { RefControl } from "comps/controls/refControl" ;
28- import { useEffect , useRef } from "react" ;
28+ import { useEffect , useRef , useState } from "react" ;
2929
3030import { AutoHeightControl } from "comps/controls/autoHeightControl" ;
3131import {
3232 client ,
33- meetingControllerChildren ,
3433} from "./videoMeetingControllerComp" ;
3534
3635import { IAgoraRTCRemoteUser } from "agora-rtc-sdk-ng" ;
@@ -61,8 +60,7 @@ const Container = styled.div<{ $style: any }>`
6160 display: flex;
6261 align-items: center;
6362 justify-content: center;
64- ` ; // ${(props) => props.$style && getStyle(props.$style)} - they should be applyed to VideoContainer only
65-
63+ ` ;
6664const VideoContainer = styled . video < { $style : any } > `
6765 height: 100%;
6866 width: 100%;
@@ -154,13 +152,9 @@ const typeOptions = [
154152 } ,
155153] as const ;
156154
157- export const videoShared = ( ) => {
158- console . log ( "data" ) ;
159- } ;
160155export const meetingStreamChildren = {
161156 autoHeight : withDefault ( AutoHeightControl , "fixed" ) ,
162157 type : dropdownControl ( typeOptions , "" ) ,
163- // onEvent: ButtonEventHandlerControl,
164158 onEvent : MeetingEventHandlerControl ,
165159 disabled : BoolCodeControl ,
166160 loading : BoolCodeControl ,
@@ -169,27 +163,28 @@ export const meetingStreamChildren = {
169163 suffixIcon : IconControl ,
170164 style : ButtonStyleControl ,
171165 viewRef : RefControl < HTMLElement > ,
172- // viewRef: RefControl<BaseStreamRef>,
173- userId : stringExposingStateControl ( "user id" , trans ( "meeting.userId" ) ) ,
166+ userId : stringExposingStateControl ( "" ) ,
174167} ;
175168
176169let 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 ( ) ;
181174
182- useEffect ( ( ) => {
183- onResize ( ) ;
184- } , [ ] ) ;
175+ useEffect ( ( ) => {
176+ onResize ( ) ;
177+ } , [ ] ) ;
185178
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 ) ;
193188 client . on (
194189 "user-published" ,
195190 async ( user : IAgoraRTCRemoteUser , mediaType : "video" | "audio" ) => {
@@ -198,10 +193,10 @@ let VideoCompBuilder = (function (props) {
198193 let userId = user . uid + "" ;
199194 if (
200195 user . hasVideo &&
201- user . uid + "" != props . userId . value &&
202- props . userId . value != ""
196+ user . uid + "" != userData . user &&
197+ userData . user != ""
203198 ) {
204- props . onEvent ( "videoActiveInactive " ) ;
199+ props . onEvent ( "videoOn " ) ;
205200 }
206201 const element = document . getElementById ( userId ) ;
207202 if ( element ) {
@@ -212,10 +207,12 @@ let VideoCompBuilder = (function (props) {
212207 const remoteTrack = await client . subscribe ( user , mediaType ) ;
213208 if (
214209 user . hasAudio &&
215- user . uid + "" != props . userId . value &&
216- props . userId . value != ""
210+ user . uid + "" != userData . user &&
211+ userData . user != ""
217212 ) {
218- props . onEvent ( "audioMuteUnmute" ) ;
213+ userData . audiostatus = user . hasVideo ;
214+
215+ props . onEvent ( "audioUnmuted" ) ;
219216 }
220217 remoteTrack . play ( ) ;
221218 }
@@ -227,67 +224,67 @@ let VideoCompBuilder = (function (props) {
227224 if ( mediaType === "audio" ) {
228225 if (
229226 ! user . hasAudio &&
230- user . uid + "" != props . userId . value &&
231- props . userId . value != ""
227+ user . uid + "" != userData . user &&
228+ userData . user != ""
232229 ) {
233- props . onEvent ( "audioMuteUnmute" ) ;
230+ userData . audiostatus = user . hasVideo ;
231+ props . onEvent ( "audioMuted" ) ;
234232 }
235233 }
236234 if ( mediaType === "video" ) {
237235 if (
238236 ! user . hasVideo &&
239- user . uid + "" != props . userId . value &&
240- props . userId . value != ""
237+ user . uid + "" != userData . user &&
238+ userData . user != ""
241239 ) {
242- props . onEvent ( "videoActiveInactive " ) ;
240+ props . onEvent ( "videoOff " ) ;
243241 }
244242 }
245243 }
246244 ) ;
247- } , [ props . userId . value ] ) ;
245+ setUserId ( userData . user ) ;
246+ }
247+ } , [ props . userId . value ] ) ;
248248
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 ( ) ;
286286} ) ( ) ;
287287
288- // interface BaseStreamRef {
289- // shared: () => void;
290- // }
291288VideoCompBuilder = class extends VideoCompBuilder {
292289 override autoHeight ( ) : boolean {
293290 return this . children . autoHeight . getView ( ) ;
0 commit comments