AgoraIO-Extensions / react-native-agora

React Native around the Agora RTC SDKs for Android and iOS agora
https://www.agora.io
MIT License
622 stars 228 forks source link

Black screen show in remote user device in react native 0.71.8 version #672

Closed yash1898-coder closed 1 year ago

yash1898-coder commented 1 year ago

Describe the bug import { ClientRoleType, createAgoraRtcEngine, IRtcEngine, RtcSurfaceView, ChannelProfileType, } from 'react-native-agora';

const LiveStreamingScreen = ({navigation,route}) => { const agoraEngineRef = useRef(IRtcEngine);
const [isJoined, setIsJoined] = useState(false); // Indicates if the local user has joined the channel const [audience, setAudience] = useState(false); const [remoteUid, setRemoteUid] = useState(0); // Uid of the remote user const [message, setMessage] = useState(''); // Message to the user const [isCoHost, setIsCoHost] = useState(false);

const setupVideoSDKEngine = async () => { try { // use the helper function to get permissions if (Platform.OS === 'android') { await getPermission(); } agoraEngineRef.current = createAgoraRtcEngine(); const agoraEngine = agoraEngineRef.current;

    agoraEngine.registerEventHandler({
      onJoinChannelSuccess: () => {
        console.log('Successfully joined the channel ' + channelName);
        setIsJoined(true);
      },
      onUserJoined: (_connection, Uid) => {
        console.log('Remote user joined with uid ' + Uid);
        setRemoteUid(Uid);
      },
      onUserOffline: (_connection, Uid) => {
        console.log('Remote user left the channel. uid: ' + Uid);
        setRemoteUid(0);
      },
      })

    agoraEngine.initialize({
      appId: appId,
      channelProfile: ChannelProfileType.ChannelProfileLiveBroadcasting,
    });

    agoraEngineRef.current?.enableVideo()
    agoraEngineRef.current?.enableAudio();

  } catch (e) {
    console.log(e);
  }
};

const join = async () => { if (isJoined) { return; } try { if (agoraEngineRef.current) { console.log("Get Response Data:::::",token, channelName, remoteUid,route.params?.isHost) agoraEngineRef.current.setChannelProfile( ChannelProfileType.ChannelProfileLiveBroadcasting ); if (route.params?.isHost) { agoraEngineRef.current.startPreview(); agoraEngineRef.current.joinChannel(token, channelName, 0, { clientRoleType: isCoHost? ClientRoleType.ClientRoleBroadcaster:ClientRoleType.ClientRoleAudience }); } else { setAudience(true) agoraEngineRef.current.joinChannel(token, channelName, remoteUid, { clientRoleType: ClientRoleType.ClientRoleAudience, }); } setIsJoined(true); } } catch (e) { console.log(e); } };

retrun(
<View>
  {  route.params.isHost?
    <> 
    {isJoined&&
    <>
      <React.Fragment key={0}>
        <RtcSurfaceView canvas={{ uid: 0 }} style={[styles.fullscreenVideoView]} />
      </React.Fragment>

{isCoHost &&

} } : <> {audience && } } } ) } "react": "18.2.0", "react-native": "0.71.8", "react-native-agora": "^4.2.0", please help me to solve this issue.
yash1898-coder commented 1 year ago

Please help me solve this issue my token and appId details are right and the remote user channel connects successfully but shows a black screen, also video enable issue is not there because I added ClientRoleType.ClientRoleBroadcaster then the camera is shown but I was using ClientRoleType.ClientRoleAudience then shows a black screen.

HackX-IN commented 1 year ago

Hello ! I am also facing the same issue when the clients joins the channel it’s shows up with the black screen and the version I am using is the same

"react": "18.2.0", "react-native": "0.71.8", "react-native-agora": "^4.2.0",

please help me to solve this issue.

LichKing-2234 commented 1 year ago

is our example working?

HackX-IN commented 1 year ago

is our example working?

I have tried example too the same issue occurs client or audience shows up with black screen

yash1898-coder commented 1 year ago

the same issue faced in the example. working fine in the host device but a black screen is shown in the remote user (audience) device.

HackX-IN commented 1 year ago

we have finally solved this issue pacakage used : react-native --version 0.72.0 and react-native-agora --version 4.2.0

LichKing-2234 commented 1 year ago

seem like https://github.com/facebook/react-native/issues/37057?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.