api.video-reactnative-live-stream icon indicating copy to clipboard operation
api.video-reactnative-live-stream copied to clipboard

[Feat]: Flag to activate/deactivate camera

Open adaerodriguez opened this issue 4 months ago • 0 comments

Version

2.0.1

Environment that reproduces the issue

Both platform: Android and iOS

Use case description

Hi guys, I have a little problem. I'm developing an application that only shows the camera when some button is pressed, but I can't get it, because when I hide the view I get a null reference error. Is there any way to hide/show the camera from a button?

Here is my code:

return (
    <View style={isStreaming ? styles.container : {}}>
      {(isStreaming) && (
        <ApiVideoLiveStreamView
          // @ts-ignore
          ref={ref}
          style={styles.containerVideo}
          camera="back"
          enablePinchedZoom={true}
          video={{
            fps: 30,
            resolution: '720p',
            bitrate: 2 * 1024 * 1024, // # 2 Mbps
            gopDuration: 1, // 1 second
          }}
          audio={{
            bitrate: 128000,
            sampleRate: 44100,
            isStereo: true,
          }}
          isMuted={false}
          onConnectionSuccess={onConnectionSuccess}
          onConnectionFailed={onConnectionFailed}
          onDisconnect={onDisconnect}
        />
      )}
      <ButtonStreaming
        isStreaming={isStreaming}
        onPress={onPressStreamStart}
      />
    </View>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    height: '100%',
    width: '100%',
    alignItems: 'center',
    position: 'absolute',
  },
  containerVideo: {
    flex: 1,
    backgroundColor: colors.black,
    alignSelf: 'stretch',
  },
});

When I press the ButtonStreaming button I should see the camera and start streaming.

Proposed solution

Can a flag be added to activate/deactivate the camera preview?

Thanks!!

Alternative solutions

No response

adaerodriguez avatar Oct 22 '24 11:10 adaerodriguez