@andoto/react
https://www.npmjs.com/package/@andoto/react
Installation
NPM:
npm install @andoto/react --save
Yarn:
yarn add @andoto/react
How to use
import React from "react";
import { Video, useVideoControls } from "@andoto/react";
const MyComponent = props => {
const videoId = `yourVideoId`;
const controls = useVideoControls(videoId);
return (
<div>
<Video id={videoId} />
<button onClick={() => controls.play()}>Play Video</button>
<button onClick={() => controls.pause()}>Pause Video</button>
</div>
);
};
export default MyComponent;
Video Controls
play(): Promise<void, (Error)>
Play the video, if it is paused.
controls
.play()
.then(() => {
// the video is now playing
})
.catch(error => {
console.error(error);
});