Вот мои прослушиватели событий изменения состояния видеоплитки. :
Код: Выделить всё
const [localDevice, setLocalDevice] = useState({
videoEnabled: false,
videoTileId: null
})
const [remoteDevice, setRemoteDevice] = useState({
videoEnabled: false,
videoTileId: null
})
// ---------- ON ATTENDEE START VIDEO ----------
useEffect(()=>{
onAddVideoTileSubscription.current = getSDKEventEmitter().addListener(
MobileSDKEvent.OnAddVideoTile,
tileState => {
if(tileState.isLocal){
setLocalDevice({
videoEnabled: true,
videoTileId: tileState.tileId
})
}else if(!tileState.isLocal){
setRemoteDevice({
videoEnabled: true,
videoTileId: tileState.tileId
})
}
},
);
return () => {
if (onAddVideoTileSubscription.current) {
onAddVideoTileSubscription.current.remove();
}
};
},[])
// ---------- ON ATTENDEE END VIDEO ----------
useEffect(()=>{
onRemoveVideoTileSubscription.current = getSDKEventEmitter().addListener(
MobileSDKEvent.OnRemoveVideoTile,
tileState => {
if(tileState.isLocal){
setLocalDevice({
videoEnabled: false,
videoTileId: tileState.tileId
})
}else if(!tileState.isLocal){
setRemoteDevice({
videoEnabled: false,
videoTileId: tileState.tileId
})
}
},
);
return () => {
if (onRemoveVideoTileSubscription.current) {
onRemoveVideoTileSubscription.current.remove();
}
};
},[])
Код: Выделить всё
return (
{remoteDevice.videoEnabled ? (
): (
null
)}
{localDevice.videoEnabled ? (
): (
null
)}
(
)}
ItemSeparatorComponent={() => }
keyExtractor={item => item}
/>
NativeFunction.setMute(!currentMuted)}
/>
NativeFunction.setCameraOn(!localDevice.videoEnabled)
}
/>
NativeFunction.stopMeeting()} />
);
Код: Выделить всё
callContainer:{
backgroundColor: '#1D1D1D',
justifyContent: 'center',
alignItems: 'center',
height: '100%',
justifyContent: 'flex-start'
},
localDeviceVideoContainer:{
position: 'absolute',
bottom: 100,
right: 15,
height: 175,
width: 132,
zIndex: 1,
elevation: 1,
},
localDeviceVideo:{
height: '100%',
width: '100%'
},
remoteDeviceVideoContainer:{
height: '100%',
width: '100%',
backgroundColor:'pink',
},
remoteDeviceVideo:{
width: '100%',
height: '100%',
},
Подробнее здесь: https://stackoverflow.com/questions/787 ... nvideoview