Skip to content

Computes the duration of an mp3 buffer in node or browser.

Notifications You must be signed in to change notification settings

Kesymaru/react-native-get-mp3-duration

 
 

Repository files navigation

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 twitter

About

Computes the duration of an mp3 buffer in node or browser.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 90.2%
  • JavaScript 9.8%