1.0.6 • Published 5 years ago

react-frame-picker v1.0.6

Weekly downloads
3
License
ISC
Repository
-
Last release
5 years ago

react-frame-picker

Frame-by-frame video previews, with the ability to use or download individual frames.

Props

PropTypeRequiredDefault
srcstringYes-The URL of the video to be previewed. Anything that works as src with a standard HTML5 video element should be fine here.
actionfunctionYes-Callback that takes a single argument - the file object of the extracted frame. ie: (file) => console.log('Do something with the file').
stepnumberNo0.04The value (in seconds) of the increment when stepping forward or backward through the video.
disabledbooleanNofalseDisables the 'open frame picker' button.
useFrameButtonTextStringNo"Use Frame"The text that is displayed in the button that invokes the action prop.
buttonRenderFunctionfunctionNo-A render function to pass a custom button to open the frame-picker. Render function is passed onClick and disabled, ie: ({ onClick, disabled }) => <YourCustomButton onClick={onClick} disabled={disabled}>. If not provided, a default button will be rendered.
buttonStyleobjectNo_Can be passsed to style the default 'open frame-picker' button, as an alternative to passing an custom button render function.

Basic Usage:

import FramePicker from 'react-frame-picker';

export class SomeComponent extends React.Component {
  useFile = (file) => {
    console.log(file);
  }

  render() {
    return (
      <FramePicker
        step={0.03}
        src="https://some.video/file.mp4"
        useFrameButtonText="Use this frame"
        action={this.useFile}
      />
    );
  }
}

Passing a custom trigger button:

import FramePicker from 'react-frame-picker';

export class SomeComponent extends React.Component {
  useFile = (file) => {
    console.log(file);
  }

  renderCustomButton = ({ onClick, disabled }) => {
    return (
      <button onClick={onClick} disabled={disabled}>A Custom Button</button>
    );
  }

  render() {
    return (
      <FramePicker
        step={0.03}
        src="https://some.video/file.mp4"
        buttonRenderFunction={this.renderCustomButton}
        action={this.useFile}
      />
    );
  }
}