{"action":"created","issue":{"url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/726","repository_url":"https://api.github.com/repos/react-native-community/react-native-camera","labels_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/726/comments","events_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/726/events","html_url":"https://github.com/react-native-community/react-native-camera/issues/726","id":231680885,"node_id":"MDU6SXNzdWUyMzE2ODA4ODU=","number":726,"title":"Support switching between front and back camera while recording","user":{"login":"theronpatrick","id":1417999,"node_id":"MDQ6VXNlcjE0MTc5OTk=","avatar_url":"https://avatars1.githubusercontent.com/u/1417999?v=4","gravatar_id":"","url":"https://api.github.com/users/theronpatrick","html_url":"https://github.com/theronpatrick","followers_url":"https://api.github.com/users/theronpatrick/followers","following_url":"https://api.github.com/users/theronpatrick/following{/other_user}","gists_url":"https://api.github.com/users/theronpatrick/gists{/gist_id}","starred_url":"https://api.github.com/users/theronpatrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theronpatrick/subscriptions","organizations_url":"https://api.github.com/users/theronpatrick/orgs","repos_url":"https://api.github.com/users/theronpatrick/repos","events_url":"https://api.github.com/users/theronpatrick/events{/privacy}","received_events_url":"https://api.github.com/users/theronpatrick/received_events","type":"User","site_admin":false},"labels":[{"id":392175401,"node_id":"MDU6TGFiZWwzOTIxNzU0MDE=","url":"https://api.github.com/repos/react-native-community/react-native-camera/labels/Feature%20Request","name":"Feature Request","color":"4078c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-05-26T16:54:27Z","updated_at":"2018-10-11T11:32:08Z","closed_at":null,"author_association":"NONE","body":"<!-- Love react-native-camera? Please consider supporting our collective: 👉  https://opencollective.com/react-native-camera/donate -->\r\n\r\nSo far I've been very successful using this library, except for one issue. If I'm recording a video and switch the 'type', aka which camera is being used, it stops the recording. \r\n\r\nIf changing the prop always discontinues recording, is there another way to switch between front and back-facing cameras while recording a video?\r\n\r\n\r\nMy component is: \r\n\r\n```import React from 'react';\r\nimport { StyleSheet, Text, View, Button } from 'react-native';\r\nimport Camera from \"react-native-camera\"\r\n\r\nexport default class App extends React.Component {\r\n\r\n  constructor(props) {\r\n    super(props);\r\n\r\n    this.camera = null;\r\n\r\n    this.state = {\r\n      camera: {\r\n        aspect: Camera.constants.Aspect.fill,\r\n        captureTarget: Camera.constants.CaptureTarget.cameraRoll,\r\n        captureMode: Camera.constants.CaptureMode.video,\r\n        type: Camera.constants.Type.back,\r\n        orientation: Camera.constants.Orientation.auto,\r\n        flashMode: Camera.constants.FlashMode.auto,\r\n      },\r\n      isRecording: false\r\n    };\r\n  }\r\n\r\n  takePicture = () => {\r\n    const options = {};\r\n    //options.location = ...\r\n    this.camera.capture({metadata: options})\r\n      .then((data) => console.log(data))\r\n      .catch(err => console.error(err));\r\n  }\r\n\r\n  startRecording = () => {\r\n    if (this.camera) {\r\n      this.camera.capture()\r\n      .then((data) => console.log(data))\r\n      .catch(err => console.error(err));\r\n\r\n      this.setState({\r\n        isRecording: true\r\n      });\r\n    }\r\n  }\r\n\r\n  stopRecording = () => {\r\n    console.log(\"stop recording called\");\r\n    if (this.camera) {\r\n      this.camera.stopCapture();\r\n      this.setState({\r\n        isRecording: false\r\n      });\r\n    }\r\n  }\r\n\r\n  switchType = () => {\r\n    let newType;\r\n    const { back, front } = Camera.constants.Type;\r\n\r\n    if (this.state.camera.type === back) {\r\n      newType = front;\r\n    } else if (this.state.camera.type === front) {\r\n      newType = back;\r\n    }\r\n\r\n    this.setState({\r\n      camera: {\r\n        ...this.state.camera,\r\n        type: newType,\r\n      },\r\n    });\r\n  }\r\n\r\n  render() {\r\n\r\n    let recordButton;\r\n    if (!this.state.isRecording) {\r\n      recordButton = <Button\r\n        onPress={this.startRecording}\r\n        title=\"Start Recording\"\r\n        color=\"#841584\">\r\n      </Button>\r\n    } else {\r\n      recordButton = <Button\r\n        onPress={this.stopRecording}\r\n        title=\"Stop Recording\"\r\n        color=\"#841584\">\r\n      </Button>\r\n    }\r\n\r\n    let typeButton;\r\n    if (this.state.camera.type === Camera.constants.Type.back) {\r\n      typeButton = <Button\r\n        onPress={this.switchType}\r\n        title=\"Switch Camera Mode (back)\"\r\n        color=\"#841584\">\r\n      </Button>\r\n    } else {\r\n      typeButton = <Button\r\n        onPress={this.switchType}\r\n        title=\"Switch Camera Mode (front)\"\r\n        color=\"#841584\">\r\n      </Button>\r\n    }\r\n\r\n    return (\r\n      <View style={styles.container}>\r\n        <Text>React Native is Fun!</Text>\r\n        {recordButton}\r\n        {typeButton}\r\n\r\n        <Camera\r\n          ref={(cam) => {\r\n            this.camera = cam;\r\n          }}\r\n          style={styles.preview}\r\n          aspect={this.state.camera.aspect}\r\n          captureTarget={this.state.camera.captureTarget}\r\n          captureAudio={true}\r\n          type={this.state.camera.type}\r\n          captureMode={this.state.camera.captureMode}\r\n          flashMode={this.state.camera.flashMode}\r\n          mirrorImage={false}\r\n        />\r\n      </View>\r\n    );\r\n  }\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n  container: {\r\n    flex: 1,\r\n    backgroundColor: '#fff',\r\n    alignItems: 'center',\r\n    justifyContent: 'center',\r\n  },\r\n  preview: {\r\n    justifyContent: 'flex-end',\r\n    alignItems: 'center',\r\n    width: \"50%\",\r\n    height: \"50%\"\r\n  },\r\n  capture: {\r\n    flex: 0,\r\n    backgroundColor: '#fff',\r\n    borderRadius: 5,\r\n    color: '#000',\r\n    padding: 10,\r\n    margin: 40\r\n  }\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/comments/428921247","html_url":"https://github.com/react-native-community/react-native-camera/issues/726#issuecomment-428921247","issue_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/726","id":428921247,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODkyMTI0Nw==","user":{"login":"n1ru4l","id":14338007,"node_id":"MDQ6VXNlcjE0MzM4MDA3","avatar_url":"https://avatars2.githubusercontent.com/u/14338007?v=4","gravatar_id":"","url":"https://api.github.com/users/n1ru4l","html_url":"https://github.com/n1ru4l","followers_url":"https://api.github.com/users/n1ru4l/followers","following_url":"https://api.github.com/users/n1ru4l/following{/other_user}","gists_url":"https://api.github.com/users/n1ru4l/gists{/gist_id}","starred_url":"https://api.github.com/users/n1ru4l/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n1ru4l/subscriptions","organizations_url":"https://api.github.com/users/n1ru4l/orgs","repos_url":"https://api.github.com/users/n1ru4l/repos","events_url":"https://api.github.com/users/n1ru4l/events{/privacy}","received_events_url":"https://api.github.com/users/n1ru4l/received_events","type":"User","site_admin":false},"created_at":"2018-10-11T11:32:08Z","updated_at":"2018-10-11T11:32:08Z","author_association":"COLLABORATOR","body":"@ColinJS @Lucas-Hudson Spamming this issue will not result in any progress. If you want the functionality, you can implement it and send a pull request or wait until someone else implements it."}}
{"actor":{"display_login":"n1ru4l"}}