Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created April 23, 2020 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/bd6dd85153e7814a661836da008bd56f to your computer and use it in GitHub Desktop.
Save aaronksaunders/bd6dd85153e7814a661836da008bd56f to your computer and use it in GitHub Desktop.
Ionic Native Plugins in ReactJS with Capacitor
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