1.3.1 • Published 7 months ago

react-mirt v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-mirt

An react audio trimmer component ~copied~ inspired by iOS. It can be used to set a start and end time for an audio file in order to process it further, e.g. using ffmpeg. You can also zoom in to make finer adjustments by holding down the handle.

ezgif-1-bfe867f0ff

Install

  yarn add react-mirt
  # npm install react-mirt

Use

import Mirt from 'react-mirt';
import 'react-mirt/dist/css/react-mirt.css';

function App() {
  return <Mirt file={myWayTooLongAudioFile} />;
}

Props

PropertyTypeDescription
fileFileThe audio file to be trimmed
classNamestringAdditional classes on the root element
styleobjectAdditional styles on the root element
optionsobjectSee options below

Options

ParameterTypeDefaultDescription
showButtonbooleantrueShow/hide the play button
waveformColorstringrgba(255, 255, 255, 0.5)Color of the waveform as CSS color value
waveformBarWidthnumber0.5Width of waveform bar depending on the block width (e.g. 0.5 equals half of the block width)
waveformBlockWidthnumber4Width of waveform block (sum of bar and space)
waveformLoadingbooleanfalseAnimate waveform until actual waveform is loaded
fineTuningDelaynumber500Delay (ms) for switching to fine tuning (0 disables fine tuning)
fineTuningScalenumber5Zoom factor for fine tuning
startnumberOverwrite current start value
endnumberOverwrite current end value

Callback functions

EventTypeDescription
onChange({ start: number; current: number; end: number }) => void;Returns the start and end values and the current playhead handle position, if one of these changed
onAudioLoaded(audio: HTMLAudioElement) => void;Triggered as soon as the audio element has been loaded, returns the HTML audio element
onWaveformLoaded() => void;Triggered as soon as the waveform has been generated
onError(error: Error) => void;Triggered when an error has occurred, returns the error

Styling

There are several ways to customise the appearance. I recommend overwriting the CSS variables. But you can also import the sass file and overwrite its variables or you add your own styles on top.

VariableSass VariableDefaultDescription
--mirt-height$height3remHeight of the component
--mirt-border-radius$border-radius0.3remBorder radius of component and inner frame
--mirt-background-color$background-color#333Background color (also of button and waveform)
--mirt-playhead-width$playhead-width0.35remPlayhead width
--mirt-playhead-color$playhead-color#fffPlayhead color
--mirt-frame-border-width$frame-border-width0.3remWidth of (colored) frame border
--mirt-frame-color$frame-color#409f80Color of frame
--mirt-handle-width$handle-width1.2remWidth of start and end handles
--mirt-handle-icon-width$handle-icon-width0.75remIcon width of start and end handles
--mirt-handle-icon-color$handle-icon-color#333Icon color of start and end handles
--mirt-handle-transition-duration$handle-transition-duration500msTransition duration start, end and playhead handles
--mirt-button-width$button-width3remWidth of play/pause button
--mirt-button-border-color$button-border-color#222Border (right) color of play/pause button
--mirt-button-hover-color$button-hover-color#444Hover color of play/pause button
--mirt-button-icon-width$button-icon-width1remIcon width of play/pause button
--mirt-button-icon-color$button-icon-color#fffIcon color of play/pause button

License

MIT

1.3.1

7 months ago

1.3.0

1 year ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago