Created
April 23, 2020 02:36
-
-
Save aaronksaunders/bd6dd85153e7814a661836da008bd56f to your computer and use it in GitHub Desktop.
Ionic Native Plugins in ReactJS with Capacitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { | |
IonContent, | |
IonHeader, | |
IonPage, | |
IonTitle, | |
IonToolbar, | |
IonButton, | |
} from "@ionic/react"; | |
import "./Home.css"; | |
import { RouteComponentProps } from "react-router"; | |
import { | |
MediaCapture, | |
MediaFile, | |
CaptureError, | |
CaptureImageOptions, | |
CaptureVideoOptions, | |
} from "@ionic-native/media-capture"; | |
const Home: React.FC<RouteComponentProps> = ({ history }) => { | |
const doMediaCapture = async () => { | |
let options: CaptureVideoOptions = { limit: 1, duration: 30 }; | |
let capture:any = await MediaCapture.captureVideo(options); | |
console.log((capture[0] as MediaFile).fullPath) | |
}; | |
return ( | |
<IonPage id="home-page"> | |
<IonHeader> | |
<IonToolbar> | |
<IonTitle>Video Test</IonTitle> | |
</IonToolbar> | |
</IonHeader> | |
<IonContent fullscreen> | |
<IonButton onClick={() => doMediaCapture()}>VIDEO CAPATURE</IonButton> | |
</IonContent> | |
</IonPage> | |
); | |
}; | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment