Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 5872 Name code Date/Time 20-Dec-2023 10:38:07 AM

Copy text from below

import React, { useState, useRef } from 'react';

import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';

import { Camera } from 'expo-camera';

import { Video } from 'expo-av';

 

export default function App() {

  const [hasPermission, setHasPermission] = useState(null);

  const [cameraType, setCameraType] = useState(Camera.Constants.Type.back);

  const [isRecording, setIsRecording] = useState(false);

  const cameraRef = useRef(null);

  const videoRef = useRef(null);

 

  const startRecord = async () => {

    if (cameraRef.current) {

      try {

        const { uri } = await cameraRef.current.recordAsync();

        console.log('Recording started:', uri);

        setIsRecording(true);

      } catch (error) {

        console.error('Error starting recording:', error);

      }

    }

  };

 

  const stopRecord = async () => {

    if (cameraRef.current) {

      try {

        const { uri } = await cameraRef.current.stopRecording();

        console.log('Recording stopped:', uri);

        setIsRecording(false);

      } catch (error) {

        console.error('Error stopping recording:', error);

      }

    }

  };

 

  const takePicture = async () => {

    if (cameraRef.current) {

      try {

        const { uri } = await cameraRef.current.takePictureAsync();

        console.log('Picture taken:', uri);

      } catch (error) {

        console.error('Error taking picture:', error);

      }

    }

  };

 

  const switchCamera = () => {

    setCameraType(

      cameraType === Camera.Constants.Type.back

        ? Camera.Constants.Type.front

        : Camera.Constants.Type.back

    );

  };

 

  const onCameraPermission = async () => {

    const { status } = await Camera.requestPermissionsAsync();

    setHasPermission(status === 'granted');

  };

 

  if (hasPermission === null) {

    return <View />;

  }

 

  if (hasPermission === false) {

    return <Text>No access to camera</Text>;

  }

 

  return (

    <View style={styles.container}>

      <Camera

        style={styles.camera}

        type={cameraType}

        ref={cameraRef}

        onCameraReady={() => console.log('Camera ready')}

      >

        <View style={styles.controls}>

          <TouchableOpacity

            style={styles.button}

            onPress={isRecording ? stopRecord : startRecord}

          >

            <Text style={styles.text}>{isRecording ? 'Stop' : 'Record'}</Text>

          </TouchableOpacity>

          <TouchableOpacity style={styles.button} onPress={takePicture}>

            <Text style={styles.text}>Take Picture</Text>

          </TouchableOpacity>

          <TouchableOpacity style={styles.button} onPress={switchCamera}>

            <Text style={styles.text}>Switch Camera</Text>

          </TouchableOpacity>

        </View>

      </Camera>

      {isRecording && (

        <Video

          ref={videoRef}

          style={styles.videoPreview}

          source={{ uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4' }}

          useNativeControls

        />

      )}

    </View>

  );

}

 

const styles = StyleSheet.create({

  container: {

    flex: 1,

  },

  camera: {

    flex: 1,

  },

  controls: {

    flex: 1,

    flexDirection: 'row',

    justifyContent: 'center',

    alignItems: 'flex-end',

    marginBottom: 20,

  },

  button: {

    backgroundColor: 'white',

    borderRadius: 5,

    padding: 15,

    marginHorizontal: 10,

  },

  text: {

    fontSize: 16,

  },

  videoPreview: {

    flex: 1,

    position: 'absolute',

    top: 0,

    left: 0,

    right: 0,

    bottom: 0,

  },

});

 





comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
5596 ASF 21-Feb-2023 03:09:59 PM
5595 Test 1 FEB23 21-Feb-2023 03:09:31 PM
5594 Sexy-Movies 21-Feb-2023 11:37:26 AM
5593 Test 1 feb21 20-Feb-2023 05:16:11 PM
5592 . 17-Feb-2023 12:28:00 PM
5591 Test1 Feb17 16-Feb-2023 09:48:33 PM
5590 Nusfi Recipe 16-Feb-2023 05:26:40 PM
5589 . 16-Feb-2023 05:22:59 PM
5588 MET 15-Feb-2023 10:39:58 AM
5587 Test12Feb15 14-Feb-2023 10:35:57 PM
5586 Test11Feb15 14-Feb-2023 10:30:34 PM
5585 Test 8Feb15 14-Feb-2023 10:27:35 PM
5584 Test 3 Feb15 14-Feb-2023 10:24:31 PM
5583 Test 2 Feb15 14-Feb-2023 03:28:53 PM
5582 Test 1 Feb15 14-Feb-2023 03:26:12 PM
5581 asddf 14-Feb-2023 03:25:47 PM
5580 asdf 14-Feb-2023 03:25:40 PM
5579 asdf 14-Feb-2023 03:25:33 PM
5578 asf 14-Feb-2023 03:25:27 PM
5577 asdf 14-Feb-2023 03:25:19 PM
5576 asdf 14-Feb-2023 03:25:13 PM
5575 asdf 14-Feb-2023 03:25:05 PM
5574 asdf 14-Feb-2023 03:24:56 PM
5573 asdf 14-Feb-2023 03:24:50 PM
5572 asdf 14-Feb-2023 03:24:41 PM
5571 asdf 14-Feb-2023 03:24:33 PM
5570 asdf 14-Feb-2023 03:24:23 PM
5569 asdf 14-Feb-2023 03:24:16 PM

[First] [Prev] 11 | 12
 
web counter
web counter


To report any error messages or bugs, or other issues, please send email at: info@pakproject.com