1.0.3 • Published 2 years ago

react-native-get-mp3-duration v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-get-mp3-duration

Computes the duration of an mp3 buffer in react native

NPM Build Status JavaScript Style Guide

Install

npm install --save react-native-get-mp3-duration
# or
yarn add react-native-get-mp3-duration

Usage

import getMP3Duration from 'get-mp3-duration';
import {FileSystem} from 'react-native-file-access'; // or another lib that read the file into base64

const bufferStr = await FileSystem.readFile('fixtures/vbr.mp3', 'base64')
const duration = await getMP3Duration(bufferStr)

console.log(duration, 'ms') // 285727 ms

Duration in seconds

import getMP3Duration from 'get-mp3-duration';
import {FileSystem} from 'react-native-file-access'; // or another lib that read the file into base64

const bufferStr = await FileSystem.readFile('fixtures/vbr.mp3', 'base64')
const duration = await getMP3Duration(bufferStr, 'seconds')

console.log(duration, 'seconds') // 285.727 seconds

Related

  • mp3-duration this package is a fork of mp3-duration to add browser support.
  • vmsg is an optimized mp3 recorder for the web which ports the lame mp3 encoder to wasm.

License

MIT © Travis Fischer

Support my OSS work by following me on twitter