Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTC callbacks UserMuteVideo,RemoteVideoStateChanged and UserEnableVideo are not triggered. #94

Closed
teefortayyab opened this issue Nov 8, 2022 · 7 comments
Assignees

Comments

@teefortayyab
Copy link

I have been trying to use agora's RTC Callbacks to detect remote user's video stream status using UserMuteVideo,RemoteVideoStateChanged and UserEnableVideo callbacks but I am unable to get any callback triggered when the remote user is pausing/resuming the video.

@EkaanshArora
Copy link
Contributor

can you share a code snippet?

@teefortayyab
Copy link
Author

@EkaanshArora I have been facing issues customizing design view with the default import of the package, So, I used separate components to customize the design accordingly to requirements. Everything is working fine except some callbacks.

Working callbacks are EndCall, UserJoined, UserOffline. But UserMuteVideo,RemoteVideoStateChanged and UserEnableVideo are not triggered when the remote user is pausing/resuming the video.

You can see the code snippet in other comment.

@teefortayyab
Copy link
Author

@EkaanshArora

const props = {
    rtcProps: {
      appId: config.appId,
      layout: 1, //pinned layout
      channel: roomId ? roomId.toString() : null,
    },
    callbacks: {
      EndCall: () => handleEndCall(),
      Warning: (warning) => console.log('WARNING:::', warning),
      Error: (error) => console.log('ERROR:::', error),
      ConnectionStateChanged: (e) => console.log('CONNECTION STATE CHANGED:::', e),
      JoinChannelSuccess: (e) => console.log('JOIN CHANNEL SUCCESS:::', e),
      RtcStats: (e) => console.log('RTC STATS:::', e),
      ConnectionBanned: () => console.log('CONNECTION BANNED'),
      ConnectionInterrupted: () => console.log('CONNECTION INTERRUPTED'),
      RequestToken: () => console.log('REQUEST TOKEN'),
      TokenPrivilegeWillExpire: () => console.log('TOKEN PRIVILEGE WILL EXPIRE'),
      ConnectionLost: () => console.log('CONNECTION LOST'),
      ApiCallExecuted: () => console.log('API CALL EXECUTED'),
      UserJoined: () => handleStartCall(),
      UserOffline: () => callEnded(),
      UserMuteVideo: (uid, muted) => console.log({ uid, muted }),
      RemoteVideoStateChanged: (uid, state, reason, elapsed) => console.log({ uid, state, reason, elapsed }),
      UserEnableVideo: (uid, enabled) => console.log({ uid, enabled }),
    },
  };
  
  <PropsProvider value={props}>
      <View style={{ flex: 1 }}>
        {showEndCallAnimation && (
          <Image
            source={require('@assets/img/VideoToNoVideoTransition.gif')}
            style={styles.animatedAbsoluteContainerView}
          />
        )}
        <PermissionModal
          showPermissionsModal={showPermissionsModal}
          setShowPermissionsModal={setShowPermissionsModal}
        />
        <CallStatus callConnected={callConnected.current} />
        <View style={{ flex: 1 }}>
          <RtcConfigure>
            <QuestionnaireModal questions={questions} />
            {showQuestionPopup && <QuestionPopUp questions={questions} />}
            <MaxUidConsumer>
              {(maxUsers) => (maxUsers[0] ? <MaxVideoView user={maxUsers[0]} key={maxUsers[0].uid} /> : null)}
            </MaxUidConsumer>
            <View style={styles.videoContainer}>
              <MinUidConsumer>
                {(minUsers) =>
                  minUsers.map((user) =>
                    user.video ? (
                      <>
                        <MinVideoView user={user} key={user.uid} />
                        <LocalUserContextComponent>
                          <SwitchCamera />
                        </LocalUserContextComponent>
                      </>
                    ) : (
                      <View
                        style={{
                          width: 120,
                          height: 200,
                          justifyContent: 'center',
                          alignItems: 'center',
                          backgroundColor: '#161C24',
                        }}>
                        <Image
                          source={{
                            uri: authUser?.profile?.photos?.length
                              ? authUser?.profile?.photos[0]
                              : DEFAULT_PROFILE_IMAGE,
                          }}
                          resizeMode='cover'
                          style={{ height: 75, width: 75, borderRadius: 100 }}
                        />
                        <LocalUserContextComponent>
                          <SwitchCamera />
                        </LocalUserContextComponent>
                      </View>
                    )
                  )
                }
              </MinUidConsumer>
            </View>
            <LocalControls />
          </RtcConfigure>
        </View>
        <View style={styles.parent}>
          <View style={styles.innerChild1}>
            <Image
              source={{ uri: receiverImage }}
              resizeMode='cover'
              style={{ height: 30, width: 30, borderRadius: 15 }}
            />
            <Text style={styles.innerChild1Text}>{receiverName && age ? `${receiverName}, ${age}` : ''}</Text>
          </View>
          {callConnected.current && roomData && mixerId ? (
            <View style={styles.innerChild2}>
              <ProgressBar stopCallAutomatically={handleEndCall} roomData={roomData} />
            </View>
          ) : (
            <ActivityIndicator color={'#281E48'} size={30} />
          )}
        </View>
      </View>
    </PropsProvider>

@EkaanshArora
Copy link
Contributor

This looks like a bug, I’m out of office so I can try and fix this next week. In the meantime you can access the engine from the RtcContext and attach the event listener manually.

@EkaanshArora EkaanshArora self-assigned this Nov 9, 2022
@teefortayyab
Copy link
Author

@EkaanshArora Can you share any example for How can I attach a listener manually from RtcContext?

@teefortayyab
Copy link
Author

@EkaanshArora Can you share any update or steps so that I can use RTC event in my application?

@EkaanshArora
Copy link
Contributor

You can look at this file for an example of how to access the rtcEngine.
Here's a snippet to listen for an event:

function AddEvent() {
  const {RtcEngine} = useContext(RtcContext);
  useEffect(()=>{
    RtcEngine.addListener('RemoteVideoStateChanged', (uid, state, reason, elapsed) => {
      // do things
    })
  },[])
  return null
}

// render it in your tree
...
    <AddEvent />
  </MinUidConsumer>
</View>

I'll try and fix this in the coming week, so you can just use the callbacks object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants